#include "bits/stdc++.h"
using namespace std;
using namespace std;
 
int main(){
    char chs[]=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string codes[32]={
        "101","000000","000011","10010001","010001","000001","100101","10011010"
        ,"0101","0001","110","01001","10011011","010000","0111","10011000"
        ,"0110","00100","10011001","10011110","00101","111","10011111","1000"
        ,"00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
 
    string s;
    while(getline(cin,s)){
        string t;
        for(int i=0;i<s.size();i++){
            t += codes[find(chs,chs+32,s[i])-chs];
        }
        if(t.size()%5)t.append(5-t.size()%5,'0');
        for(int i=0;i<t.size();i+=5){
            int n=0;
            for(int j=0;j<5;j++)n = n<<1|t[i+j]-'0';
            if(n<26)cout<<(char)('A'+n);
            else cout<<" .,-'?"[n-26];
        }
        cout<<endl;
    }
    return 0;
}