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