# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <utility>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
# include <bitset>
using namespace std;
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
 
 
int main()
{
	string a;
	pss table[]={
		pss("101"," "),
		pss("000000","'"),
		pss("000011",","),
		pss("10010001","-"),
		pss("010001","."),
		pss("000001","?"),
		pss("100101","A"),
		pss("10011010","B"),
		
		pss("0101","C"),
		pss("0001","D"),
		pss("110","E"),
		pss("01001","F"),
		pss("10011011","G"),
		pss("010000","H"),
		pss("0111","I"),
		pss("10011000","J"),
		
		pss("0110","K"),
		pss("00100","L"),
		pss("10011001","M"),
		pss("10011110","N"),
		pss("00101","O"),
		pss("111","P"),
		pss("10011111","Q"),
		pss("1000","R"),
		
		pss("00110","S"),
		pss("00111","T"),
		pss("10011100","U"),
		pss("10011101","V"),
		pss("000010","W"),
		pss("10010010","X"),
		pss("10010011","Y"),
		pss("10010011","Z")
	};
	
	map<string,string> enc,dec(table,table+32);
	
	for(char c='A';c<='Z';c++)
	{
		stringstream ss;
		ss<< static_cast< bitset<5> >(c-'A');
		string C;C+=c;
		enc[C]=ss.str();
	}
	enc[" "]="11010";
	enc["."]="11011";
	enc[","]="11100";
	enc["-"]="11101";
	enc["'"]="11110";
	enc["?"]="11111";
	
	while(getline(cin,a))
	{
		string b,c,ans;
		for(int i=0;i<a.size();i++)
		{
			string now;now+=a[i];
			b+=enc[now];
		}
		for(int i=0;i<b.size();i++)
		{
			c+=b[i];
			if(dec.count(c))
			{
				ans+=dec[c];
				c="";
			}
		}
		if(dec.count(c))ans+=dec[c];
		cout<<ans<<endl;
	}
	
}