#include<bits/stdc++.h>
using namespace std;
map<char, string>m1; map<char, string>m2;
const string str = " \',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string s, t, ans;
int p;
bool f(char ch) {
	if (p + m2[ch].size() > t.size())return 0;
	if (t.substr(p, m2[ch].size()) == m2[ch]) {
		p += m2[ch].size(); ans += ch;
		return 1;
	}
	return 0;
}
signed main() {
	{
		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";
	}
	{
		m2[' '] = "101";
		m2['\''] = "000000";
		m2[','] = "000011";
		m2['-'] = "10010001";
		m2['.'] = "010001";
		m2['?'] = "000001";
		m2['A'] = "100101";
		m2['B'] = "10011010";
		m2['C'] = "0101";
		m2['D'] = "0001";
		m2['E'] = "110";
		m2['F'] = "01001";
		m2['G'] = "10011011";
		m2['H'] = "010000";
		m2['I'] = "0111";
		m2['J'] = "10011000";
		m2['K'] = "0110";
		m2['L'] = "00100";
		m2['M'] = "10011001";
		m2['N'] = "10011110";
		m2['O'] = "00101";
		m2['P'] = "111";
		m2['Q'] = "10011111";
		m2['R'] = "1000";
		m2['S'] = "00110";
		m2['T'] = "00111";
		m2['U'] = "10011100";
		m2['V'] = "10011101";
		m2['W'] = "000010";
		m2['X'] = "10010010";
		m2['Y'] = "10010011";
		m2['Z'] = "10010000";
	}
	while (getline(cin, s)) {
		ans.clear(); t.clear(); p = 0;
		for (char ch : s)t += m1[ch];
		bool b = 1;
		while (b) {
			b = 0;
			for (char ch : str)if (f(ch))b = 1;
		}
		cout << ans << endl;
	}
}
