
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
  map<string,char>t2;
  map<char,string>t1;
  t1['A']="00000";
  t1['B']="00001";
  t1['C']="00010";
  t1['D']="00011";
  t1['E']="00100";
  t1['F']="00101";
  t1['G']="00110";
  t1['H']="00111";
  t1['I']="01000";
  t1['J']="01001";
  t1['K']="01010";
  t1['L']="01011";
  t1['M']="01100";
  t1['N']="01101";
  t1['O']="01110";
  t1['P']="01111";
  t1['R']="10001";
  t1['S']="10010";
  t1['T']="10011";
  t1['U']="10100";
  t1['V']="10101";
  t1['W']="10110";
  t1['X']="10111";
  t1['Y']="11000";
  t1['Z']="11001";
  t1[' ']="11010";
  t1['.']="11011";
  t1[',']="11100";
  t1['-']="11101";
  t1['\'']="11110";
  t1['?']="11111";
  t1['Q']="10000";

  t2["101"]=' ';
  t2["000000"]='\'';
  t2["000011"]=',';
  t2["10010001"]='-';
  t2["010001"]='.';
  t2["000001"]='?';
  t2["100101"]='A';
  t2["10011010"]='B';
  t2["0101"]='C';
  t2["0001"]='D';
  t2["110"]='E';
  t2["01001"]='F';
  t2["10011011"]='G';
  t2["010000"]='H';
  t2["0111"]='I';
  t2["10011000"]='J';
  t2["0110"]='K';
  t2["00100"]='L';
  t2["10011001"]='M';
  t2["10011110"]='N';
  t2["00101"]='O';
  t2["111"]='P';
  t2["10011111"]='Q';
  t2["1000"]='R';
  t2["00110"]='S';
  t2["00111"]='T';
  t2["10011100"]='U';
  t2["10011101"]='V';
  t2["000010"]='W';
  t2["10010010"]='X';
  t2["10010011"]='Y';
  t2["10010000"]='Z';
 
 string s,t;
  while(getline(cin,s)){
    t="";
    for(int i=0;i<s.size();i++)
      t+=t1[s[i]];
    string ans;
    for(int i=0;i<t.size();i++){
      ans+=t[i];
      if(t2[ans]){
	cout<<t2[ans];
	ans="";
      }
    }
    cout<<endl;
  }
}