#include<iostream>
#include<map>
#include<string>

using namespace std;


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

  table2.insert( map<string, char>::value_type( "101", ' ' ) );
  table2.insert( map<string, char>::value_type( "000000", '"' ) );
  table2.insert( map<string, char>::value_type( "000011", ',' ) );
  table2.insert( map<string, char>::value_type( "1001001", '-' ) );
  table2.insert( map<string, char>::value_type( "01001", '.' ) );
  table2.insert( map<string, char>::value_type( "000001", '?' ) );
  table2.insert( map<string, char>::value_type( "100101", 'A' ) );
  table2.insert( map<string, char>::value_type( "10011010", 'B' ) );
  table2.insert( map<string, char>::value_type( "0101", 'C' ) );
  table2.insert( map<string, char>::value_type( "0001", 'D' ) );
  table2.insert( map<string, char>::value_type( "110", 'E' ) );
  table2.insert( map<string, char>::value_type( "01001", 'F' ) );
  table2.insert( map<string, char>::value_type( "10011011", 'G' ) );
  table2.insert( map<string, char>::value_type( "010000", 'H' ) );
  table2.insert( map<string, char>::value_type( "0111", 'I' ) );
  table2.insert( map<string, char>::value_type( "10011000", 'J' ) );
  table2.insert( map<string, char>::value_type( "0110", 'K' ) );
  table2.insert( map<string, char>::value_type( "00100", 'L' ) );
  table2.insert( map<string, char>::value_type( "10011001", 'M' ) );
  table2.insert( map<string, char>::value_type( "10011110", 'N' ) );
  table2.insert( map<string, char>::value_type( "00101", 'O' ) );
  table2.insert( map<string, char>::value_type( "111", 'P' ) );
  table2.insert( map<string, char>::value_type( "10011111", 'Q' ) );
  table2.insert( map<string, char>::value_type( "1000", 'R' ) );
  table2.insert( map<string, char>::value_type( "00110", 'S' ) );
  table2.insert( map<string, char>::value_type( "00111", 'T' ) );
  table2.insert( map<string, char>::value_type( "10011100", 'U' ) );
  table2.insert( map<string, char>::value_type( "10011101", 'V' ) );
  table2.insert( map<string, char>::value_type( "000010", 'W' ) );
  table2.insert( map<string, char>::value_type( "10010010", 'X' ) );
  table2.insert( map<string, char>::value_type( "10010011", 'Y' ) );
  table2.insert( map<string, char>::value_type( "10010000", 'Z' ) );
  string cipher;
  while(getline(cin, cipher)){
    int i, len;
    string text;
    for(i=0; i<cipher.length(); i++)text+=table1[cipher[i]];
    for(i=0, len; i<text.length(); i+=len){
      bool found = false;
      for(len=3; i+len<text.length(); len++){
        if(table2.count(text.substr(i, len))!=0){
          found = true;
          break;
        }
      }
      if(!found)break;
      cout << table2[text.substr(i,len)];
    }
    cout << endl;
  }
}