#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <vector>
using namespace std;
#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORD(prom, a, b) for(int prom = (a); prom > (b); prom--)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define PB push_back
#define MP make_pair
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
map<string,char> to;
map<char, string> rev;
map<char, int> from;
vector<int> code;
string line, conv;
map<string,char>::iterator it;
map<char, int>::iterator itt;
int main ()
{
to.insert(MP(".-", 'A'));
to.insert(MP("-...", 'B'));
to.insert(MP("-.-.", 'C'));
to.insert(MP("-..", 'D'));
to.insert(MP(".", 'E'));
to.insert(MP("..-.", 'F'));
to.insert(MP("--.", 'G'));
to.insert(MP("....", 'H'));
to.insert(MP("..", 'I'));
to.insert(MP(".---", 'J'));
to.insert(MP("-.-", 'K'));
to.insert(MP(".-..", 'L'));
to.insert(MP("--", 'M'));
to.insert(MP("-.", 'N'));
to.insert(MP("---", 'O'));
to.insert(MP(".--.", 'P'));
to.insert(MP("--.-", 'Q'));
to.insert(MP(".-.", 'R'));
to.insert(MP("...", 'S'));
to.insert(MP("-", 'T'));
to.insert(MP("..-", 'U'));
to.insert(MP("...-", 'V'));
to.insert(MP(".--", 'W'));
to.insert(MP("-..-", 'X'));
to.insert(MP("-.--", 'Y'));
to.insert(MP("--..", 'Z'));
to.insert(MP("..--", '_'));
to.insert(MP(".-.-", ','));
to.insert(MP("---.", '.'));
to.insert(MP("----", '?'));
for (it = to.begin(); it != to.end(); it++) rev.insert(MP(it->second, it->first));
for (it = to.begin(); it != to.end(); it++) from.insert(MP(it->second, it->first.length()));
while (getline(cin, line))
{
code.clear();
conv.clear();
FOR(i, 0, line.length())
{
itt = from.find(line[i]);
code.PB(itt->second);
conv += rev.find(itt->first)->second;
}
int pl = 0;
FORDE(i, code.size() - 1, 0)
{
string tmp;
tmp.clear();
FOR(j, 0, code[i]) tmp += conv[pl + j];
cout << to.find(tmp)->second;
pl += code[i];
}
cout << endl;
}
return 0;
}