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

string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
string code[] = {"100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","100010010","10010011","10010000","101","010001","000011","10010001","000000","000001"};
int hexa[] = {16,8,4,2,1};

string bitconvert(int n){
	string a;
	int b;
	for(int i = 0;i < 5;++i){
		b = n / hexa[i];
		a += (char)(b + '0');
		n -= b * hexa[i];
	}
	return a;
}
int main(){
	string input,convert,tmp,output;
	int now;
	getline(cin,input);
	output = convert = tmp = "";
	for(int i = 0;i < input.size();++i){
		for(int j = 0;j < str.size();++j){
			if(input[i] == str[j]){
				now = j;
				break;
			}
		}
		convert += bitconvert(now);
	}
	now = -1;
	for(int i = 0;i < convert.size();++i){
		tmp += convert[i];
		for(int j = 0;j < str.size();++j){
			if(tmp == code[j]){
				now = j;
				break;
			}
		}
		if(now != -1){
			output += str[now];
			tmp = "";
			now = -1;
		}
	}
	cout << output << endl;
	return 0;
}