#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
using namespace std;
map<char,string>M;
map<string,char>S;
void init(){
    for(int i=0;i<26;i++){
        bitset<5>bs(i);
        M[i+'A']=bs.to_string();
    }
    M[' ']="11010";M['.']="11011";M[',']="11100";
    M['-']="11101";M['\'']="11110";M['?']="11111";

    S["101"]=' ';S["000000"]='\'';S["000011"]=',';
    S["10010001"]='-';S["010001"]='.';S["000001"]='?';
    S["100101"]='A';S["11011010"]='B';S["0101"]='C';
    S["0001"]='D';S["110"]='E';S["01001"]='F';
    S["10011011"]='G';S["010000"]='H';S["0111"]='I';
    S["10011000"]='J';S["0110"]='K';S["00100"]='L';
    S["10011001"]='M';S["10011110"]='N';S["00101"]='O';
    S["111"]='P';S["10011111"]='Q';S["1000"]='R';
    S["00110"]='S';S["00111"]='T';S["10011100"]='U';
    S["10011101"]='V';S["000010"]='W';S["10010010"]='X';
    S["10010011"]='Y';S["10010000"]='Z';
}
int main(){
    init();
    string str;
    while(getline(cin,str)){
        string code="";
        for(int i=0;i<str.length();i++){
            code+=M[str[i]];
        }

        string ans="";
        string r="";
        for(int i=0;i<code.length();i++){
            r+=code[i];
            if(S.find(r)!=S.end()){
                ans+=S[r];
                r="";
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}