#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

typedef map<char,string> M;

map<char,string> s;
map<string,char> g;
int main()
{
    s['A'] = "00000";
    s['B'] = "00001";
    s['C'] = "00010";
    s['D'] = "00011";
    s['E'] = "00100";
    s['F'] = "00101";
    s['G'] = "00110";
    s['H'] = "00111";
    s['I'] = "01000";
    s['J'] = "01001";
    s['K'] = "01010";
    s['L'] = "01011";
    s['M'] = "01100";
    s['N'] = "01101";
    s['O'] = "01110";
    s['P'] = "01111";
    s['Q'] = "10000";
    s['R'] = "10001";
    s['S'] = "10010";
    s['T'] = "10011";
    s['U'] = "10100";
    s['V'] = "10101";
    s['W'] = "10110";
    s['X'] = "10111";
    s['Y'] = "11000";
    s['Z'] = "11001";
    s[' '] = "11010";
    s['.'] = "11011";
    s[','] = "11100";
    s['-'] = "11101";
    s['\''] = "11110";
    s['?'] = "11111";
    g["100101"] = 'A';
    g["10011010"] = 'B';
    g["0101"] = 'C';
    g["0001"] = 'D';
    g["110"] = 'E';
    g["01001"] = 'F';
    g["10011011"] = 'G';
    g["010000"] = 'H';
    g["0111"] = 'I';
    g["10011000"] = 'J';
    g["0110"] = 'K';
    g["00100"] = 'L';
    g["10011001"] = 'M';
    g["10011110"] = 'N';
    g["00101"] = 'O';
    g["111"] = 'P';
    g["10011111"] = 'Q';
    g["1000"] = 'R';
    g["00110"] = 'S';
    g["00111"] = 'T';
    g["10011100"] = 'U';
    g["10011101"] = 'V';
    g["000010"] = 'W';
    g["10010010"] = 'X';
    g["10010011"] = 'Y';
    g["10010000"] = 'Z';
    g["101"] = ' ';
    g["000000"] = '\'';
    g["000011"] = ',';
    g["10010001"] = '-';
    g["010001"] = '.';
    g["000001"] = '?';

    string str;
    while (getline(cin, str)) {
        string v;
        for (int i = 0; i < str.size(); i++)
            v += s[str[i]];
        for (int i = 0; i < v.size(); i++) {
            string y = "";
            for (int j = i; j < v.size(); j++) {
                y += v[j];
                if (g.find(y) != g.end()) {
                    cout << g[y];
                    i += y.size() -1;
                }
            }
        }
        cout << endl;
    }

    return 0;
}