#include<iostream>
#include<map>
using namespace std;
void make_map();
map < char,string> t;
map <string,char> u;

int main(){
  make_map();
  int x;
  string str,A,B;
  while(getline(cin,str)){
    A="";
    for(int i=0;i<(int)str.size();i++){
      A+=t[str[i]];
    }
    x=0;B="";
    while(x<(int)A.size()){
      B.push_back(A[x]);
      if(u[B]!='\0'){
	cout<<u[B];
	B="";
      }
      x++;
    }
    cout<<endl;
  }
  return 0;
}

void make_map(){
  t['A']="00000";
  t['B']="00001";
  t['C']="00010";
  t['D']="00011";
  t['E']="00100";
  t['F']="00101";
  t['G']="00110";
  t['H']="00111";

  t['I']="01000";
  t['J']="01001";
  t['K']="01010";
  t['L']="01011";
  t['M']="01100";
  t['N']="01101";
  t['O']="01110";
  t['P']="01111";  

  t['Q']="10000";
  t['R']="10001";
  t['S']="10010";
  t['T']="10011";
  t['U']="10100";
  t['V']="10101";
  t['W']="10110";
  t['X']="10111";
  
  t['Y']="11000";
  t['Z']="11001";
  t[' ']="11010";
  t['.']="11011";
  t[',']="11100";
  t['-']="11101";
  t['\'']="11110";
  t['?']="11111";

  u["101"]=' ';
  u["000000"]='\'';
  u["000011"]=',';
  u["10010001"]='-';
  u["010001"]='.';
  u["000001"]='?';
  u["100101"]='A';
  u["10011010"]='B';
  u["0101"]='C';
  u["0001"]='D';
  u["110"]='E';
  u["01001"]='F';
  u["10011011"]='G';
  u["010000"]='H';
  u["0111"]='I';
  u["10011000"]='J';
  u["0110"]='K';
  u["00100"]='L';
  u["10011001"]='M';
  u["10011110"]='N';
  u["00101"]='O';
  u["111"]='P';
  u["10011111"]='Q';
  u["1000"]='R';
  u["00110"]='S';
  u["00111"]='T';
  u["10011100"]='U';
  u["10011101"]='V';
  u["000010"]='W';
  u["10010010"]='X';
  u["10010011"]='Y';
  u["10010000"]='Z';
  

}