#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;

string mkzero(int len) {
    char str[80];
    sprintf(str, "%0*d", len, 0);
    return string(str);
}

int main() {
    const char * fromA = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    const char * toA[] = {
        "101",
        "000000",
        "000011",
        "10010001",
        "010001",
        "000001",
        "100101",
        "10011010",
        "0101",
        "0001",
        "110",
        "01001",
        "10011011",
        "010000",
        "0111",
        "10011000",
        "0110",
        "00100",
        "10011001",
        "10011110",
        "00101",
        "111",
        "1001111",
        "1000",
        "00110",
        "00111",
        "10011100",
        "10011101",
        "000010",
        "10010010",
        "10010011",
        "10010000",
        ""
    };

    const char * fromB[] = {
        "00000",
        "00001",
        "00010",
        "00011",
        "00100",
        "00101",
        "00110",
        "00111",
        "01000",
        "01001",
        "01010",
        "01011",
        "01100",
        "01101",
        "01110",
        "01111",
        "10000",
        "10001",
        "10010",
        "10011",
        "10100",
        "10101",
        "10110",
        "10111",
        "11000",
        "11001",
        "11010",
        "11011",
        "11100",
        "11101",
        "11110",
        "11111",
        ""
    };

    const char * toB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

    map<char, string> enc;
    for(int i = 0, len = strlen(fromA); i < len; i++) {
        enc.insert(make_pair(fromA[i], string(toA[i])));
    }

    map<string, char> dec;
    for(int i = 0, len = strlen(toB); i < len; i++) {
        dec.insert(make_pair(string(fromB[i]), toB[i]));
    }

#if 0
    for(map<char, string>::const_iterator it = enc.begin(); it != enc.end(); ++it) {
        cerr << it->first << " -> " << it->second << endl;
    }

    for(map<string, char>::const_iterator it = dec.begin(); it != dec.end(); ++it) {
        cerr << it->first << " -> " << it->second << endl;
    }
#endif

    for(string line; getline(cin, line); ) {
        ostringstream ss;
        for(int i = 0; i < (int)line.length(); i++)
            ss << enc[line[i]];
        if(ss.str().size() % 5 > 0) ss << mkzero(5 - ss.str().size() % 5);
        for(int i = 0; i < (int)ss.str().size() / 5; i++) {
            cout << dec[ss.str().substr(5*i, 5)];
        }
        cout << endl;
    }
}