#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int ln;
  string s[256],t,u;
  map<string,char> v;
  s['A']="00000";
  s['B']="00001";
  s['C']="00010";
  s['D']="00011";
  s['E']="00100";
  s['F']="00101";
  s['G']="00110";
  s['H']="00111";
  s['I']="01000";
  s['J']="01001";
  s['K']="01010";
  s['L']="01011";
  s['M']="01100";
  s['N']="01101";
  s['O']="01110";
  s['P']="01111";
  s['Q']="10000";
  s['R']="10001";
  s['S']="10010";
  s['T']="10011";
  s['U']="10100";
  s['V']="10101";
  s['W']="10110";
  s['X']="10111";
  s['Y']="11000";
  s['Z']="11001";
  s[' ']="11010";
  s['.']="11011";
  s[',']="11100";
  s['-']="11101";
  s['\'']="11110";
  s['?']="11111";
  v["101"]=' ';
  v["000000"]='\'';
  v["000011"]=',';
  v["10010001"]='-';
  v["010001"]='.';
  v["000001"]='?';
  v["100101"]='A';
  v["10011010"]='B';
  v["0101"]='C';
  v["0001"]='D';
  v["110"]='E';
  v["01001"]='F';
  v["10011011"]='G';
  v["010000"]='H';
  v["0111"]='I';
  v["10011000"]='J';
  v["0110"]='K';
  v["00100"]='L';
  v["10011001"]='M';
  v["10011110"]='N';
  v["00101"]='O';
  v["111"]='P';
  v["10011111"]='Q';
  v["1000"]='R';
  v["00110"]='S';
  v["00111"]='T';
  v["10011100"]='U';
  v["10011101"]='V';
  v["000010"]='W';
  v["10010010"]='X';
  v["10010011"]='Y';
  v["10010000"]='Z';
  while(getline(cin,t)){
    ln=t.length();
    u="";
    for(i=0;i<ln;i++)
      u+=s[(int)t[i]];
    ln=u.length();
    t="";
    for(i=0;i<ln;i=j){
      for(j=i+1;j<ln;j++){
	if(v[u.substr(i,j-i)]!=0){
	  t+=v[u.substr(i,j-i)];
	  break;
	}
      }
    }
    cout<<t<<endl;
  }
  return 0;
}