#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream f("siruri.in");
char sir[255], *p, *v[255], *aux;
int i, j, n=0;
f.get(sir,255);
p=strtok(sir," ,.;");
while(p){
n++;
p[0]=toupper(p[0]);
p[strlen(p)-1]=toupper(p[strlen(p)-1]);
v[n]=p;
p=strtok(NULL," ,.;");
}
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++)
if(strlen(v[i])>strlen(v[j])){
aux=v[i]; v[i]=v[j]; v[j]=aux;
}
for(i=1;i<=n;i++)
cout<<v[i]<<' ';
return 0;
}