/*
	AOJ_0111: Doctor's Memorable Codes
*/
#include	<iostream>
#include	<string>
#include	<map>

using namespace std;

string Convert_CtoCode(string);
string Convert_CodetoString(string);

int main(void) {
	string str;

	while (1) {
		getline(cin, str);
		if (cin.eof()) { break; }
		cout << Convert_CodetoString(Convert_CtoCode(str)) << endl;
	}
}

string Convert_CtoCode(string str) {
	string result;
	map<char, string> List;

	List['A'] = "00000";		List['I'] = "01000";		List['Q'] = "10000";		List['Y'] = "11000";
	List['B'] = "00001";		List['J'] = "01001";		List['R'] = "10001";		List['Z'] = "11001";
	List['C'] = "00010";		List['K'] = "01010";		List['S'] = "10010";		List[' '] = "11010";
	List['D'] = "00011";		List['L'] = "01011";		List['T'] = "10011";		List['.'] = "11011";
	List['E'] = "00100";		List['M'] = "01100";		List['U'] = "10100";		List[','] = "11100";
	List['F'] = "00101";		List['N'] = "01101";		List['V'] = "10101";		List['-'] = "11101";
	List['G'] = "00110";		List['O'] = "01110";		List['W'] = "10110";		List['\''] = "11110";
	List['H'] = "00111";		List['P'] = "01111";		List['X'] = "10111";		List['?'] = "11111";

	string::iterator it = str.begin();
	while (it != str.end()) {
		result += List[*it];
		it++;
	}

	return result;
}

string Convert_CodetoString(string str) {
	string result, tmp;
	map<string, char> List;

	List["101"] = ' ';		List["0101"] = 'C';		List["0110"] = 'K';		List["00110"] = 'S';
	List["000000"] = '\'';	List["0001"] = 'D';		List["00100"] = 'L';	List["00111"] = 'T';
	List["000011"] = ',';	List["110"] = 'E';		List["10011001"] = 'M';	List["10011100"] = 'U';
	List["10010001"] = ' '; List["01001"] = 'F';	List["10011110"] = 'N';	List["10011101"] = 'V';
	List["010001"] = '.';	List["10011011"] = 'G';	List["00101"] = 'O';	List["000010"] = 'W';
	List["000001"] = '?';	List["010000"] = 'H';	List["111"] = 'P';		List["10010010"] = 'X';
	List["100101"] = 'A';	List["0111"] = 'I';		List["10011111"] = 'Q';	List["10010011"] = 'Y';
	List["10011010"] = 'B'; List["10011000"] = 'J';	List["1000"] = 'R';		List["10010000"] = 'Z';

	string::iterator it_a = str.begin();
	while (it_a != str.end()) {
		tmp.clear();
		string::iterator it_b = it_a;
		while (it_b != str.end()) {
			tmp += *it_a;
			it_a++;
			if (List[tmp] != 0) { result += List[tmp]; break; }
			it_b++;
		}
	}

	return result;
}