#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
using namespace std;
map<char,string> m;
map<string,char> n;
int main()
{
  m.insert( map<char,string>::value_type('A',"00000") );
  m.insert( map<char,string>::value_type('B',"00001") );
  m.insert( map<char,string>::value_type('C',"00010") );
  m.insert( map<char,string>::value_type('D',"00011") );
  m.insert( map<char,string>::value_type('E',"00100") );
  m.insert( map<char,string>::value_type('F',"00101") );
  m.insert( map<char,string>::value_type('G',"00110") );
  m.insert( map<char,string>::value_type('H',"00111") );
  m.insert( map<char,string>::value_type('I',"01000") );
  m.insert( map<char,string>::value_type('J',"01001") );
  m.insert( map<char,string>::value_type('K',"01010") );
  m.insert( map<char,string>::value_type('L',"01011") );
  m.insert( map<char,string>::value_type('M',"01100") );
  m.insert( map<char,string>::value_type('N',"01101") );
  m.insert( map<char,string>::value_type('O',"01110") );
  m.insert( map<char,string>::value_type('P',"01111") );
  m.insert( map<char,string>::value_type('Q',"10000") );
  m.insert( map<char,string>::value_type('R',"10001") );
  m.insert( map<char,string>::value_type('S',"10010") );
  m.insert( map<char,string>::value_type('T',"10011") );
  m.insert( map<char,string>::value_type('U',"10100") );
  m.insert( map<char,string>::value_type('V',"10101") );
  m.insert( map<char,string>::value_type('W',"10110") );
  m.insert( map<char,string>::value_type('X',"10111") );
  m.insert( map<char,string>::value_type('Y',"11000") );
  m.insert( map<char,string>::value_type('Z',"11001") );
  m.insert( map<char,string>::value_type(' ',"11010") );
  m.insert( map<char,string>::value_type('.',"11011") );
  m.insert( map<char,string>::value_type(',',"11100") );
  m.insert( map<char,string>::value_type('-',"11101") );
  m.insert( map<char,string>::value_type('\'',"11110") );
  m.insert( map<char,string>::value_type('?',"11111") );
  n.insert( map<string,char>::value_type("101",' ') );
  n.insert( map<string,char>::value_type("000000",'\'') );
  n.insert( map<string,char>::value_type("000011",',') );
  n.insert( map<string,char>::value_type("10010001",'-') );
  n.insert( map<string,char>::value_type("010001",'.') );
  n.insert( map<string,char>::value_type("000001",'?') );
  n.insert( map<string,char>::value_type("100101",'A') );
  n.insert( map<string,char>::value_type("10011010",'B') );
  n.insert( map<string,char>::value_type("0101",'C') );
  n.insert( map<string,char>::value_type("0001",'D') );
  n.insert( map<string,char>::value_type("110",'E') );
  n.insert( map<string,char>::value_type("01001",'F') );
  n.insert( map<string,char>::value_type("10011011",'G') );
  n.insert( map<string,char>::value_type("010000",'H') );
  n.insert( map<string,char>::value_type("0111",'I') );
  n.insert( map<string,char>::value_type("10011000",'J') );
  n.insert( map<string,char>::value_type("0110",'K') );
  n.insert( map<string,char>::value_type("00100",'L') );
  n.insert( map<string,char>::value_type("10011001",'M') );
  n.insert( map<string,char>::value_type("10011110",'N') );
  n.insert( map<string,char>::value_type("00101",'O') );
  n.insert( map<string,char>::value_type("111",'P') );
  n.insert( map<string,char>::value_type("10011111",'Q') );
  n.insert( map<string,char>::value_type("1000",'R') );
  n.insert( map<string,char>::value_type("00110",'S') );
  n.insert( map<string,char>::value_type("00111",'T') );
  n.insert( map<string,char>::value_type("10011100",'U') );
  n.insert( map<string,char>::value_type("10011101",'V') );
  n.insert( map<string,char>::value_type("000010",'W') );
  n.insert( map<string,char>::value_type("10010010",'X') );
  n.insert( map<string,char>::value_type("10010011",'Y') );
  n.insert( map<string,char>::value_type("10010000",'Z') );

  string s="",t;
  getline(cin,t);
  for(int i=0;i<t.length();i++){
    s += m[t[i]];
  }
  int index = 0;
  map<string,char>::iterator it;
  for(;;){
    for(it = n.begin(); it != n.end(); it++){
      string st = (*it).first;
      if(st == s.substr(index,st.length())){
        cout << (*it).second;
        index += st.length();
        break;
      }
    }
    if(it == n.end()) break;
  }
  cout << endl;
  return 0;
}