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

int main() {
	map<char,string> t;
	map<string,char> s;
	string inp,res,code;
	
	t[65]="00000";	t[66]="00001";	t[67]="00010";	t[68]="00011";
	t[69]="00100";	t[70]="00101";	t[71]="00110";	t[72]="00111";
	t[73]="01000";	t[74]="01001";	t[75]="01010";  t[76]="01011";
	t[77]="01100";	t[78]="01101";	t[79]="01110";	t[80]="01111";
	t[81]="10000";	t[82]="10001";	t[83]="10010";	t[84]="10011";	
	t[85]="10100";	t[86]="10101";	t[87]="10110";	t[88]="10111";
	t[89]="11000";	t[90]="11001";	t[32]="11010";	t[46]="11011";
	t[44]="11100";	t[45]="11101";	t[39]="11110";	t[63]="11111";
	
	s["101"]=' ';	s["000000"]='\'';	s["000011"]=',';	s["10010001"]='-';
	s["010001"]='.';	s["000001"]='?';	s["100101"]='A';	s["10011010"]='B';
	s["0101"]='C';	s["0001"]='D';	s["110"]='E';	s["01001"]='F';
	s["10011011"]='G';	s["010000"]='H';	s["0111"]='I';	s["10011000"]='J';
	s["0110"]='K';	s["00100"]='L';	s["10011001"]='M';	s["10011110"]='N';
	s["00101"]='O';	s["111"]='P';	s["10011111"]='Q';	s["1000"]='R';
	s["00110"]='S';	s["00111"]='T';	s["10011100"]='U';	s["10011101"]='V';
	s["000010"]='W';	s["10010010"]='X';	s["10010011"]='Y';	s["10010000"]='Z';
	
	while(getline(cin,inp)){
		string temp;
		int i,j;
		res="";
		code="";
		for(i=0;i<inp.length();++i){
			code += t[inp[i]];
		}
		for(i=0;i<code.length();++i){
			for(j=3;j<=8;++j){
				temp = code.substr(i,j);
				if(s.find(temp) == s.end())continue;
				res += s[temp];
				i+=j-1;
				break;
			}
		}
		cout<<res<<endl;
	}
	return 0;
}