#include <bits/stdc++.h>

using namespace std;

int main()
{
	map<string,string>P;

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

	map<char,string>PP;

	PP[65]="00000";
	PP[66]="00001";
	PP[67]="00010";
	PP[68]="00011";
	PP[69]="00100";
	PP[70]="00101";
	PP[71]="00110";
	PP[72]="00111";
	PP[73]="01000";
	PP[74]="01001";
	PP[75]="01010";
	PP[76]="01011";
	PP[77]="01100";
	PP[78]="01101";
	PP[79]="01110";
	PP[80]="01111";
	PP[81]="10000";
	PP[82]="10001";
	PP[83]="10010";
	PP[84]="10011";
	PP[85]="10100";
	PP[86]="10101";
	PP[87]="10110";
	PP[88]="10111";
	PP[89]="11000";
	PP[90]="11001";
	PP[32]="11010";
	PP[46]="11011";
	PP[44]="11100";
	PP[45]="11101";
	PP[39]="11110";
	PP[63]="11111";

	string str;

	while(getline(cin,str))
	{
		string dec;
		string set;
		string enc;

		for(int i=0;i<str.length();i++)dec+=PP[str[i]];
		for(int i=0;i<dec.length();i++)
		{
			set += dec[i];
			if(!(P[set].empty()))
			{
				enc += P[set];
				set.erase(set.begin(),set.end());
			}
		}
		cout << enc << endl;
	}
	
	return 0;
}