#include <iostream>
#include <map>
#include <string>

int main()
{
	std::map<char, std::string> m1; // char to string
	m1['A'] = "00000"; m1['B'] = "00001"; m1['C'] = "00010"; m1['D'] = "00011";
	m1['E'] = "00100"; m1['F'] = "00101"; m1['G'] = "00110"; m1['H'] = "00111";
	m1['I'] = "01000"; m1['J'] = "01001"; m1['K'] = "01010"; m1['L'] = "01011";
	m1['M'] = "01100"; m1['N'] = "01101"; m1['O'] = "01110"; m1['P'] = "01111";
	m1['Q'] = "10000"; m1['R'] = "10001"; m1['S'] = "10010"; m1['T'] = "10011";
	m1['U'] = "10100"; m1['V'] = "10101"; m1['W'] = "10110"; m1['X'] = "10111";
	m1['Y'] = "11000"; m1['Z'] = "11001"; m1[' '] = "11010"; m1['.'] = "11011";
	m1[','] = "11100"; m1['-'] = "11101"; m1['\''] = "11110"; m1['?'] = "11111";
	
	std::map<std::string, char> m2; // string to char
	m2["101"] = ' '; m2["000000"] = '\''; m2["000011"] = ','; m2["10010001"] = '-';
	m2["010001"] = '.'; m2["000001"] = '?'; m2["100101"] = 'A'; m2["10011010"] = 'B';
	m2["0101"] = 'C'; m2["0001"] = 'D'; m2["110"] = 'E'; m2["01001"] = 'F';
	m2["10011011"] = 'G'; m2["010000"] = 'H'; m2["0111"] = 'I'; m2["10011000"] = 'J';
	m2["0110"] = 'K'; m2["00100"] = 'L'; m2["10011001"] = 'M'; m2["10011110"] = 'N';
	m2["00101"] = 'O'; m2["111"] = 'P'; m2["10011111"] = 'Q'; m2["1000"] = 'R';
	m2["00110"] = 'S'; m2["00111"] = 'T'; m2["10011100"] = 'U'; m2["10011101"] = 'V';
	m2["000010"] = 'W'; m2["10010010"] = 'X'; m2["10010011"] = 'Y'; m2["10010000"] = 'Z';
	
	std::string input;
	while (getline(std::cin, input)) {
		std::string bincode;
		for (int i=0; i<input.length(); i++) bincode += m1[input[i]];
		std::string res;
		std::string tmp;
		for (int i=0; i<bincode.length(); i++) {
			tmp.push_back(bincode[i]);
			if (m2.find(tmp) != m2.end()) {
				res.push_back(m2[tmp]);
				tmp.clear();
			}
		}
		std::cout << res << std::endl;
	}
	
	return 0;
}

