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

vector< string > table1(128, string(""));
vector< char > table2(32, 0);
void set(){
    table1[65] = string("100101");
    table1[66] = string("10011010");
    table1[67] = string("0101");
    table1[68] = string("0001");
    table1[69] = string("110");
    table1[70] = string("01001");
    table1[71] = string("10011011");
    table1[72] = string("010000");
    table1[73] = string("0111");
    table1[74] = string("10011000");
    table1[75] = string("0110");
    table1[76] = string("00100");
    table1[77] = string("10011001");
    table1[78] = string("10011110");
    table1[79] = string("00101");
    table1[80] = string("111");
    table1[81] = string("10011111");
    table1[82] = string("1000");
    table1[83] = string("00110");
    table1[84] = string("00111");
    table1[85] = string("10011100");
    table1[86] = string("000010");
    table1[87] = string("000010");
    table1[88] = string("10010010");
    table1[89] = string("10010011");
    table1[90] = string("10010000");
    table1[32] = string("101");
    table1[39] = string("000000");
    table1[44] = string("000011");
    table1[45] = string("10010001");
    table1[46] = string("010001");
    table1[63] = string("000001");
    for(int i = 0; i < 26; i++){
        table2[i] = 'A' + i;
    }
    table2[26] = ' ';
    table2[27] = '.';
    table2[28] = ',';
    table2[29] = '-';
    table2[30] = '\'';
    table2[31] = '?';
}

int bToDeci(string& s){
    int ans = 0;
    string::iterator it = s.begin();
    for(int n = 0; n < 5; n++){
        if( it == s.end() ) continue;
        ans *= 2;
        ans += *it - '0';
        it++;
    }
    return ans;

}

char getBlock(string& s, string::iterator& i){
    string c = "";
    for(int n = 0; n < 5 && i != s.end(); n++, i++){
        c.append( i, i+1 );
    }
    return table2[ bToDeci( c ) ];
}

int main(){
    set();
    string data;
    while( getline(cin, data) ){
        string c;
        c = string("");
        for(string::iterator it = data.begin(); it != data.end(); it++){
            c.append( table1[*it] );
        }
        string::iterator it = c.begin();
        while( it != c.end() ){
            cout << getBlock(c, it);
        }
        cout << endl;
    }
    return 0;
}