#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    string input,word;
    getline(cin,input);
    if(input.find(" - ")!=string::npos)
    {
        cout<<"Invalid input"<<endl;
        return 0;
    }
    stringstream ss(input);
    map<int, string>ordered_words;
    while(ss>>word)
    {
        string clean_word="";
        int pos=-1;
        for(char c:word)
        {
            if(isdigit(c))
            pos=c-'0';
            else clean_word+=c;
        }
        ordered_words[pos]=clean_word;
    }
    for(auto const& [key,val]:ordered_words)
    {
        cout<<val<<(&val==&ordered_words.rbegin()->second ? "" : "");
    }
    return 0;
}