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

int main(){
	map<char,string> t;
	map<string,char> t_;
	t['A'] = "00000";
	t['B'] = "00001";
	t['C'] = "00010";
	t['D'] = "00011";
	t['E'] = "00100";
	t['F'] = "00101";
	t['G'] = "00110";
	t['H'] = "00111";
	t['I'] = "01000";
	t['J'] = "01001";
	t['K'] = "01010";
	t['L'] = "01011";
	t['M'] = "01100";
	t['N'] = "01101";
	t['O'] = "01110";
	t['P'] = "01111";
	t['Q'] = "10000";
	t['R'] = "10001";
	t['S'] = "10010";
	t['T'] = "10011";
	t['U'] = "10100";
	t['V'] = "10101";
	t['W'] = "10110";
	t['X'] = "10111";
	t['Y'] = "11000";
	t['Z'] = "11001";
	t[' '] = "11010";
	t['.'] = "11011";
	t[','] = "11100";
	t['-'] = "11101";
	t['\''] = "11110";
	t['?'] = "11111";
	t_["101"] = ' ';
	t_["000000"] = '\'';
	t_["000011"] = ',';
	t_["10010001"] = '-';
	t_["010001"] = '.';
	t_["000001"] = '?';
	t_["100101"] = 'A';
	t_["10011010"] = 'B';
	t_["0101"] = 'C';
	t_["0001"] = 'D';
	t_["110"] = 'E';
	t_["01001"] = 'F';
	t_["10011011"] = 'G';
	t_["010000"] = 'H';
	t_["0111"] = 'I';
	t_["10011000"] = 'J';
	t_["0110"] = 'K';
	t_["00100"] = 'L';
	t_["10011001"] = 'M';
	t_["10011110"] = 'N';
	t_["00101"] = 'O';
	t_["111"] = 'P';
	t_["10011111"] = 'Q';
	t_["1000"] = 'R';
	t_["00110"] = 'S';
	t_["00111"] = 'T';
	t_["10011100"] = 'U';
	t_["10011101"] = 'V';
	t_["000010"] = 'W';
	t_["10010010"] = 'X';
	t_["10010011"] = 'Y';
	t_["10010000"] = 'Z';

	string s;
	while( getline(cin,s) ){
		string s_;
		for(int i=0 ; i < s.size() ; i++ ){
			s_ += t[ s[i] ];
		}
		string ans,tmp;
		for(int i=0 ; i < s_.size() ; i++ ){
			tmp.push_back( s_[i] );
			if( t_.count(tmp) ){
				ans.push_back( t_[tmp] );
				tmp = "";
			}
		}
		cout << ans << endl;
	}
}