#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
//英语 排序
string fun1(string a)
{
for(int i=0;i<a.size();i++)
{
if(a[i]>='A'&&a[i]<='Z')
{
a[i]=a[i]-'A'+'a';
}
}
return a;
}
int fun2(string a)
{
int start=0;
if(a[0]=='+'||a[0]=='-')
{
start=1;
}
int sum=0;
for(int i=start;i<a.size();i++)
{
sum=sum*10+a[i]-'0';
}
if(a[0]=='-')
{
sum=-sum;
}
return sum;
}
bool cmp1(string a,string b)
{
return fun1(a)<fun1(b);
}
bool cmp2(string a,string b)
{
return fun2(a)<fun2(b);
}
int bz[10000];
int main()
{
while(1)
{
string s;
getline(cin,s);
if(s==".")
{
break;
}
memset(bz,0,sizeof(bz));
int js=0;
vector<string> ve1;//字符串
vector<string> ve2;//数值
string ts="";
string zhi="";
int shu=0;
for(int i=0;i<s.size();)
{
while(s[i]=='+' || s[i]=='-' ||(s[i]>='0'&&s[i]<='9'))
{
zhi=zhi+s[i];
i++;
}
//cout<<"hi0"<<endl;
if(zhi!="")
{
bz[js++]=0;//数值
ve2.push_back(zhi);
zhi="";
}
//cout<<"hi1"<<endl;
while(s[i]==','||s[i]=='.'||s[i]==' ')
{
i++;
if(i==s.size())
{
break;
}
}
//cout<<"hi2"<<endl;
if(i==s.size())
{
break;
}
//cout<<"hi3"<<endl;
while((s[i]>='a'&&s[i]<='z'||(s[i]>='A'&&s[i]<='Z')))
{
ts=ts+s[i];
i++;
}
if(ts!="")
{
bz[js++]=1;
ve1.push_back(ts);
ts="";
}
while(s[i]==','||s[i]=='.'||s[i]==' ')
{
i++;
if(i==s.size())
{
break;
}
}
if(i==s.size())
{
break;
}
}
//cout<<"hi4"<<endl;
sort(ve1.begin(),ve1.end(),cmp1);
sort(ve2.begin(),ve2.end(),cmp2);
//cout<<"hi5"<<endl;
int i=0;
int j=0;
for(int k=0;k<js;k++)
{
//cout<<k<<endl;
if(bz[k]==0)
{
cout<<ve2[i++];
}else if(bz[k]==1)
{
cout<<ve1[j++];
}
if(k==(js-1))
{
cout<<'.';
}else
{
cout<<", ";
}
}
cout<<endl;
}
return 0;
}