#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int char_to_mark(int c){
    int tmp = -1;
    for(int i = 'A'; i <= 'Z' ; ++i) {
        if (c == i) {
            tmp = i-'A';
        }
    }
    if (tmp == -1) {
        if (c == '.') {
            tmp = 27;
        }
        else if (c == ',') {
            tmp = 28;
        }
        else if (c == '-') {
            tmp = 29;
        }
        else if (c == 39) {
            tmp = 30;
        }
        else if (c == '?') {
            tmp = 31;
        }
    }
    return tmp;
}

void dec_to_bin(int dec, int* bin, int num_of_bit){
    for(int i = num_of_bit-1; i >= 0; --i) {
        bin[i] = dec%2;
        dec /= 2;
    }
}

int bin_to_dec(int* bin, int num_of_bit){
    int dec = 0;
    for(int i = num_of_bit-1; i >= 0; --i) {
        dec += bin[i] * pow(2,num_of_bit-i-1);
    }
    return dec;
}

char mark_to_char(int* bin, int num_of_bit){

    int dec = bin_to_dec(bin, num_of_bit);
    //3 bit
    if (num_of_bit == 3) {
        if (dec == 5) {
            return ' ';
        }
        else if (dec == 6) {
            return 'E';
        }
        else if (dec == 7) {
            return 'P';
        }
        else {
            return 0;
        }

    }
    //4 bit
    else if (num_of_bit == 4) {
        if (dec == 5) {
            return 'C';
        }
        else if (dec == 1) {
            return 'D';
        }
        else if (dec == 7) {
            return 'I';
        }
        else if (dec == 6) {
            return 'K';
        }
        else if (dec == 8) {
            return 'R';
        }
        else {
            return 0;
        }
    }
    //5 bit
    else if (num_of_bit == 5) {
        if (dec == 4) {
            return 'L';
        }
        else if (dec == 5) {
            return 'O';
        }
        else if (dec == 6) {
            return 'S';
        }
        else if (dec == 7) {
            return 'T';
        }
        else if (dec == 9) {
            return 'F';
        }
        else {
            return 0;
        }
    }
    //6 bit
    else if (num_of_bit == 6) {
        if (dec == 1) {
            return '?';
        }
        else if (dec == 2) {
            return 'W';
        }
        else if (dec == 3) {
            return ',';
        }
        else if (dec == 37) {
            return 'A';
        }
        else if (dec == 16) {
            return 'H';
        }
        else if (dec == 17) {
            return '.';
        }
        else if (dec == 0) {
            return 39;
        }
        else {
            return 0;
        }
    }
    //8 bit
    else if (num_of_bit == 8) {
        if (dec == 144) {
            return 'Z';
        }
        else if (dec == 145) {
            return '-';
        }
        else if (dec == 146) {
            return 'X';
        }
        else if (dec == 147) {
            return 'Y';
        }
        else if (dec == 152) {
            return 'J';
        }
        else if (dec == 153) {
            return 'M';
        }
        else if (dec == 154) {
            return 'B';
        }
        else if (dec == 155) {
            return 'G';
        }
        else if (dec == 156) {
            return 'U';
        }
        else if (dec == 157) {
            return 'V';
        }
        else if (dec == 158) {
            return 'N';
        }
        else {
            return 0;
        }
    }
}

int main(){

    string data;
    int dec;
    int bin[5];

    vector<int> mark;
    while(cin >> data) {

        mark.clear();

        for(int i = 0; i < data.length(); ++i) {
            dec = char_to_mark(data[i]);
            dec_to_bin(dec, bin, 5);
            for (int k = 0; k < 5; k++) {
                mark.push_back(bin[k]);
            }
        }
        int tmp[8],bc;
        vector<char> ans;
        ans.clear();
        int roop[] = {3, 4, 5, 6 ,8};
        char jug;
        for(vector<int>::iterator it = mark.begin() ; it != mark.end(); ++it) {
            bc = 0;
            for(vector<int>::iterator itm = it; itm != mark.end(); ++itm) {
                bc++;
            }
            for(int i = 0; i < 5; ++i) {
                if (bc < roop[i]) {
                    break;
                }
                for(int j = 0; j < roop[i]; ++j) {
                    tmp[j] = *(it+j);
                }
                jug = mark_to_char(tmp,roop[i]);
                if (jug == 0) {
                }
                else {
                    ans.push_back(jug);
                    it += roop[i]-1;
                    break;
                }

            }

        }
        for(vector<char>::iterator it = ans.begin(); it != ans.end(); ++it) {
            cout << *it;
        }
        cout << endl;
    }
}