#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  while(getline(cin,s)){
    string t="";
    rep(i,s.size()){
      if(s[i]=='A')t+="00000";
      else if(s[i]=='B')t+="00001";
      else if(s[i]=='C')t+="00010";
      else if(s[i]=='D')t+="00011";
      else if(s[i]=='E')t+="00100";
      else if(s[i]=='F')t+="00101";
      else if(s[i]=='G')t+="00110";
      else if(s[i]=='H')t+="00111";
      else if(s[i]=='I')t+="01000";
      else if(s[i]=='J')t+="01001";
      else if(s[i]=='K')t+="01010";
      else if(s[i]=='L')t+="01011";
      else if(s[i]=='M')t+="01100";
      else if(s[i]=='N')t+="01101";
      else if(s[i]=='O')t+="01110";
      else if(s[i]=='P')t+="01111";
      else if(s[i]=='Q')t+="10000";
      else if(s[i]=='R')t+="10001";
      else if(s[i]=='S')t+="10010";
      else if(s[i]=='T')t+="10011";
      else if(s[i]=='U')t+="10100";
      else if(s[i]=='V')t+="10101";
      else if(s[i]=='W')t+="10110";
      else if(s[i]=='X')t+="10111";
      else if(s[i]=='Y')t+="11000";
      else if(s[i]=='Z')t+="11001";
      else if(s[i]==' ')t+="11010";
      else if(s[i]=='.')t+="11011";
      else if(s[i]==',')t+="11100";
      else if(s[i]=='-')t+="11101";
      else if(s[i]=='\'')t+="11110";
      else if(s[i]=='?')t+="11111";
    }
    string ans="";
    rep(i,t.size()){
      if(i+3<t.size()&&t.substr(i,3)=="101")ans+=" ",i+=2;
      else if(i+3<t.size()&&t.substr(i,3)=="110")ans+="E",i+=2;
      else if(i+3<t.size()&&t.substr(i,3)=="111")ans+="P",i+=2;
      else if(i+4<t.size()&&t.substr(i,4)=="0101")ans+="C",i+=3;
      else if(i+4<t.size()&&t.substr(i,4)=="0001")ans+="D",i+=3;
      else if(i+4<t.size()&&t.substr(i,4)=="0111")ans+="I",i+=3;
      else if(i+4<t.size()&&t.substr(i,4)=="0110")ans+="K",i+=3;
      else if(i+4<t.size()&&t.substr(i,4)=="1000")ans+="R",i+=3;
      else if(i+5<t.size()&&t.substr(i,5)=="01001")ans+="F",i+=4;
      else if(i+5<t.size()&&t.substr(i,5)=="00100")ans+="L",i+=4;
      else if(i+5<t.size()&&t.substr(i,5)=="00101")ans+="O",i+=4;
      else if(i+5<t.size()&&t.substr(i,5)=="00110")ans+="S",i+=4;
      else if(i+5<t.size()&&t.substr(i,5)=="00111")ans+="T",i+=4;
      else if(i+6<t.size()&&t.substr(i,6)=="000000")ans+="'",i+=5;
      else if(i+6<t.size()&&t.substr(i,6)=="000011")ans+=",",i+=5;
      else if(i+6<t.size()&&t.substr(i,6)=="010001")ans+=".",i+=5;
      else if(i+6<t.size()&&t.substr(i,6)=="000001")ans+="?",i+=5;
      else if(i+6<t.size()&&t.substr(i,6)=="100101")ans+="A",i+=5;
      else if(i+6<t.size()&&t.substr(i,6)=="010000")ans+="H",i+=5;
      else if(i+6<t.size()&&t.substr(i,6)=="000010")ans+="W",i+=5;
      else if(i+8<t.size()&&t.substr(i,8)=="10010001")ans+="-",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011010")ans+="B",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011011")ans+="G",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011000")ans+="J",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011001")ans+="M",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011110")ans+="N",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011111")ans+="Q",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011100")ans+="U",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10011101")ans+="V",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10010010")ans+="X",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10010011")ans+="Y",i+=7;
      else if(i+8<t.size()&&t.substr(i,8)=="10010000")ans+="Z",i+=7;
    }
    cout<<ans<<endl;
  }
}