#include<cstdio>
#include<string>
#include<iostream>

using namespace std;

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

string change2(string x){
	int c=0;
	for(int i=0;i<5;i++){
		c*=2;
		c+=x[i]-'0';
	}
	if(c<=25){
		string ans;
		ans+='A'+c;
		return ans;
	}
	if(c==26)return " ";
	if(c==27)return ".";
	if(c==28)return ",";
	if(c==29)return "-";
	if(c==30)return "'";
	if(c==31)return "?";
}

int main(void){
	string s;
	while(cin && getline(cin,s)){
		string str;
		for(int i=0;i<s.size();i++){
			str+=change1(s[i]);
		}
		int plus=str.size()%5;
		if(plus>0)for(int i=0;i<5-plus;i++)str+="0";
		string res;
		for(int i=0;i<str.size()/5;i++){
			string ss;
			for(int j=0;j<5;j++)ss+=str[i*5+j];
			res+=change2(ss);
		}
		cout << res << endl;
	}
	return 0;
}