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

map<char, string> encode_table;
map<string, char> decode_table;

char decode(string s) {
//    cout << s << endl;
    return decode_table[s];
}

string encode(string s) {
    string tmp;
    for (string::iterator si = s.begin(); si != s.end(); si++) {
        tmp.append(encode_table[*si]);
    }
//    cout << tmp << endl;

    string ret;
    int tmp_len = tmp.size();
    if (tmp_len % 5 != 0) {
        tmp.append(5-tmp_len%5, '0');
        tmp_len += 5 - tmp_len % 5;
    }
    for (int i = 0; i < tmp_len; i+=5) {
        ret.push_back(decode(tmp.substr(i, 5)));
    }
    return ret;
}


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

int main() {
    string s;
    init();
    while (getline(cin, s)) {
        cout << encode(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 0