#include<iostream>
#include<string>
#include<map>
using namespace std;

int main()
{
	map<int, string> m1;
	int i,j;
	for(i = 0; i < 26; ++i)
	{
		string s;
		for(j = 4; j >= 0; --j)
			s += ((i&(1<<j))!=0)+'0';
		m1[i+'A'] = s;
	}
	m1[' '] = "11010";
	m1['.'] = "11011";
	m1[','] = "11100";
	m1['-'] = "11101";
	m1['\''] = "11110";
	m1['?'] = "11111";

	map<string, char> m2;
	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';

	string str;
	string placedStr;
	while(getline(cin, str))
	{
		placedStr = "";
		for(i = 0; i < str.size(); ++i)
			placedStr += m1[ str[i] ];
		for(i = 0; i < placedStr.size(); )
		{
			string s;
			for(j = 1; i+j < placedStr.size(); ++j)
			{
				s=placedStr.substr(i, j);
				if(m2.find(s) != m2.end())
				{
					 cout << m2[s];
					 break;
				}
			}
			i+=j;
		}
		cout << endl;
	}

	return 0;
}