#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <map>
using namespace std;

string encode(char c){
	string a[]={"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"};
	static const string str=" \',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for(int i=0;i<str.length();i++){
		if(c==str[i])return a[i];
	}
}

char decode(string s){
	string str2="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-\'?";
	std::bitset<5> b(s);
	return str2[b.to_ulong()];
}

int main(void){

	string s;
	string code="";
	std::getline(cin,s);
	for(int i=0;i<s.length();i++){
		code+=encode(s[i]);
	}

	while(std::getline(cin,s)){
		code+=encode(' ');
		for(int i=0;i<s.length();i++){
			code+=encode(s[i]);
		}
	}
	cout<<code<<endl;
	string retu="";
	for(int i=0;i<code.length();i+=5){
		try{
			string dd=code.substr(i,5);
			retu+=decode(dd);
		}catch(out_of_range e){
			code+="00000";
			string dd=code.substr(i,5);
			retu=decode(dd);
			break;
		}
	}
	cout<<retu<<endl;
	return 0;
}