#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
const int MAXN = 1000 + 10;
typedef long long LL;
/*
HDU 1106
*/
int main(){
int T;
char *str = new char[MAXN];
while( scanf("%s",str)!=EOF ){
vector<int> vec;
int len = strlen(str);
char * ptr = str;
for(int i=0; i<len; i++){
if( str[i]=='5' ){
str[i] = '\0';
if( strlen(ptr)>0 ) vec.push_back(atoi(ptr));
ptr = str+i+1;
}
}
if( strlen(ptr)>0 ) vec.push_back(atoi(ptr));
sort(vec.begin(),vec.end());
len = vec.size();
int i;
for(i=0; i<len-1; i++){
cout << vec[i] << " ";
}
cout << vec[i] << endl;
delete[] str;
str = new char[MAXN];
}
return 0;
}