#include<cstdlib>
#include<string>
using namespace std;
string tbl01[]={
	"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 tbl01_idx=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string str_AB=" .,-'?";

string to01(string &s){
	string r;
	for(int i=0;i<s.size();i++)r+=tbl01[tbl01_idx.find(s[i])];
	while(r.size()%5)r+='0';
	return r;
}
string toAB(string &s){
	string r,t;
	for(int i=0;i<s.size();i+=5){
		t=s.substr(i,5);
		int c=strtol(t.c_str(),NULL,2);
		r+=c>25?str_AB[c-26]:c+'A';
	}
	return r;
}
int main(){
	string s;
	while(getline(cin,s))s=to01(s),cout<<toAB(s)<<endl;
	return 0;
}