#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;
string henkan = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

string henkan2[] = {"101","000000", "000011",
		    "10010001", "010001",
		    "000001", "100101",
		    "10011010", "0101",
		    "0001", "110", "01001",
		    "10011011", "010000",
		    "0111", "10011000",
		    "0110","00100",
		    "10011001", "10011110",
		    "00101", "111", "10011111",
		    "1000","00110", "00111",
		    "10011100", "10011101",
		    "000010", "10010010",
		    "10010011", "10010000",
};

string ch = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";

string _10to2(int a){
  string s2;
  for(int i = 0 ; i < 5 ; i++ ){
    s2 += (a%2 + '0');
    a /= 2; 
  }
  reverse(s2.begin(),s2.end());
  return s2;
}

int main(){
  string str;
  while(cin >> str){
    string s = "";
    for(int i = 0 ; i < (int)str.size() ; i++ ){
      s += _10to2(henkan.find(str[i]));
    }
    string a = "";
    int start = 0;
    for(;;){
      int f = 0;
      for(int i = 0 ; i < 32 ; i++ ){
	for(int j = 1 ; j <= (int)henkan2[i].size()||start + j <= (int)s.size(); j++ ){
	  if(henkan2[i] == s.substr(start,j)){
	    start += j;
	    f = 1;
	    a += ch[i];
	    break;
	  }
	}
	if(f == 1)break;
      }
      if( f == 0  )break;
    }
    cout << a << endl; 
  }
  return 0;
}