#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<cctype>

using namespace std;

class CBitInt{
public:
	CBitInt(int d, int bits):d(d),bits(bits){}
	string toString(){
		int n = 0;
		string ret;
		for(int i = 0; i < bits; i++){
			ret += '0';
		}
		while( d > 0 && n < bits){
			ret[n++] = d % 2 + '0';
			d = d / 2.0;
		}
		reverse(ret.begin(), ret.end());
		return ret.substr(ret.length()-bits);
	}
private:
	int d;
	int bits;
};

string DoctorTableAD(char c){
	string s;
	if( isalpha(c) ){
		CBitInt ret(c - 'A', 5);
		return ret.toString();
	}else{
		const char symb[] = " .,-'?";
		for(int i = 0; i < sizeof(symb)/sizeof(*symb); i++){
			if( c == symb[i] ){
				CBitInt ret(i+26,5);
				return ret.toString();
			}
		}
	}
	return "00000";
}
string DoctorTableDA(string &s){
	int pos = 0;
	string ret;
	const char ctable[] = " ',-.\?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char table[][32] = {"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
	
	while( true ){
		bool bFound = false;
		for(int i = 0; i < sizeof(table)/sizeof(*table); i++){
			if( pos == s.find(table[i], pos) ){
				ret += ctable[i];
				pos += strlen(table[i]);
				bFound = true;
			}
		}
		if( !bFound ) break;
	}
	return ret;
}
string DoctorLovedDecode(string &raw){
	string s;
	string ret;
	for(unsigned int i = 0; i < raw.length(); i++){
		s += DoctorTableAD(raw[i]);
	}
	return DoctorTableDA( s );
}

int main(void){
	while(true){
		string s;

		while( true ){
			char c;
			c = cin.get();
			if( cin.eof() ) return 0;
			if( c == '\n') break;
			else s += c;
		}

		cout << DoctorLovedDecode( s ) << endl;
	}
	return 0;
}