#include <bits/stdc++.h>

using namespace std;

map<char, string> mcs;
map<string, char> msc;
int p[] = {1, 2, 4, 8, 16};

void init() {
    mcs[' '] = "101";
    mcs['\''] = "000000";
    mcs[','] = "000011";
    mcs['-'] = "10010001";
    mcs['.'] = "010001";
    mcs['?'] = "000001";
    mcs['A'] = "100101";
    mcs['B'] = "10011010";
    mcs['C'] = "0101";
    mcs['D'] = "0001";
    mcs['E'] = "110";
    mcs['F'] = "01001";
    mcs['G'] = "10011011";
    mcs['H'] = "010000";
    mcs['I'] = "0111";
    mcs['J'] = "10011000";
    mcs['K'] = "0110";
    mcs['L'] = "00100";
    mcs['M'] = "10011001";
    mcs['N'] = "10011110";
    mcs['O'] = "00101";
    mcs['P'] = "111";
    mcs['Q'] = "10011111";
    mcs['R'] = "1000";
    mcs['S'] = "00110";
    mcs['T'] = "00111";
    mcs['U'] = "10011100";
    mcs['V'] = "10011101";
    mcs['W'] = "000010";
    mcs['X'] = "10010010";
    mcs['Y'] = "10010011";
    mcs['Z'] = "10010000";

    msc["11010"] = ' ';
    msc["11011"] = '.';
    msc["11100"] = ',';
    msc["11101"] = '-';
    msc["11110"] = '\'';
    msc["11111"] = '?';
}

int main() {
    init();

    string s;
    while (getline(cin, s)) {
        string ns = "";
        for (int i = 0; i < s.size(); i++) ns += mcs[s[i]];
        while (ns.size() % 5) ns += "0";

        string ans = "";
        while (ns.size()) {
            string ss = ns.substr(0, 5);
            if (msc.find(ss) != msc.end()) ans += msc[ss];
            else {
                int sum = 0;
                reverse(ss.begin(), ss.end());
                for (int i = 0; i < 5; i++)
                    sum += p[i] * (ss[i] - '0');
                ans += (sum + 'A');
            }
            ns = ns.substr(5, ns.size() - 5);
        }

        cout << ans << endl;
    }

    return 0;
}
