#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
using namespace std;
struct Letter {
char letter;
string morse;
int size;
Letter(){}
Letter(char c, string m) {
letter = c;
morse = m;
size = m.size();
}
};
enum {
underscore = 26,
comma = 27,
period = 28,
question = 29
};
vector<Letter> dict;
void fillMorse();
string printMorse();
int getPosInDict(char c);
char getLetterByMorse(string str);
int main() {
fillMorse();
//printMorse();
string line;
while(cin >> line) {
//cout << line << endl;
string lineInMorse = "";
int morseIntSize = line.size();
int morseInt[morseIntSize];
for(int i = 0; i < morseIntSize; i++) {
int posInDict = getPosInDict(line[i]);
lineInMorse += dict[posInDict].morse;
morseInt[i] = dict[posInDict].size;
}
/*
cout << lineInMorse << endl;
for(int i = 0; i < morseIntSize; i++) {
cout << morseInt[i];
}
cout << endl;
*/
string decrypted = "";
int morsePos = 0;
for(int i = morseIntSize-1; i >= 0; i--) {
string letterInMorse = lineInMorse.substr(morsePos, morseInt[i]);
morsePos += morseInt[i];
decrypted += getLetterByMorse(letterInMorse);
}
cout << decrypted << endl;
}
return 0;
}
void fillMorse() {
dict.push_back(Letter('A', ".-"));
dict.push_back(Letter('B', "-..."));
dict.push_back(Letter('C', "-.-."));
dict.push_back(Letter('D', "-.."));
dict.push_back(Letter('E', "."));
dict.push_back(Letter('F', "..-."));
dict.push_back(Letter('G', "--."));
dict.push_back(Letter('H', "...."));
dict.push_back(Letter('I', ".."));
dict.push_back(Letter('J', ".---"));
dict.push_back(Letter('K', "-.-"));
dict.push_back(Letter('L', ".-.."));
dict.push_back(Letter('M', "--"));
dict.push_back(Letter('N', "-."));
dict.push_back(Letter('O', "---"));
dict.push_back(Letter('P', ".--."));
dict.push_back(Letter('Q', "--.-"));
dict.push_back(Letter('R', ".-."));
dict.push_back(Letter('S', "..."));
dict.push_back(Letter('T', "-"));
dict.push_back(Letter('U', "..-"));
dict.push_back(Letter('V', "...-"));
dict.push_back(Letter('W', ".--"));
dict.push_back(Letter('X', "-..-"));
dict.push_back(Letter('Y', "-.--"));
dict.push_back(Letter('Z', "--.."));
dict.push_back(Letter('_', "..--"));
dict.push_back(Letter(',', ".-.-"));
dict.push_back(Letter('.', "---."));
dict.push_back(Letter('?', "----"));
}
string printMorse() {
for(unsigned int i = 0; i < dict.size(); i++) {
cout << dict[i].letter << " = " << dict[i].morse << endl;
}
return "";
}
int getPosInDict(char c) {
if(c >= 'A' && c <= 'Z') {
return c - 'A';
} else {
switch(c) {
case '_': return underscore;
case ',': return comma;
case '.': return period;
case '?': return question;
default: return -1;
}
}
}
char getLetterByMorse(string str) {
for(unsigned int i = 0; i < dict.size(); i++) {
if(dict[i].morse == str) {
return dict[i].letter;
}
}
return '%';
}