#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

string DoctorTableAD(char c){
	string s;
	const char ctable[] = " ',-.\?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char table[][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"};
	
	for(int i = 0; i < sizeof(ctable)/sizeof(*ctable); i++){
		if(ctable[i] == c){
			s = table[i];
			break;
		}
	}
	return s;
}
int myatoi(string &bin_s){
	int ret = 0;
	unsigned int i = 0;
	while( i < bin_s.length() ){
		ret += (int)((bin_s[i] - '0') * pow(2.0, (double)((bin_s.length() - 1) - i)));
		i++;
	}
	return ret;
}
char DoctorTableDA(string &s){
	int d = myatoi(s);
	char ac[] = " .,-'?";

	for(int i = 0; i < 'Z' - 'A' + 1; i++) if(d == i) return i + 'A';
	for(int i = 0; i < sizeof(ac)/sizeof(*ac); i++) if(i + 26 == d) return ac[i];
	return ' ';
}
string DoctorLovedEncode(string &raw){
	string s;
	string ret;
	for(unsigned int i = 0; i < raw.length(); i++){
		s += DoctorTableAD(raw[i]);
	}
	// padding
	while( s.length() % 5 != 0 ) s += '0';

	for(unsigned int i = 0; i < s.length() / 5; i++){
		string subs = s.substr(i*5,5);
		ret += DoctorTableDA( subs );
	}
	return ret;
}

int main(void){
	while(true){
		string s;

		while( true ){
			char c;
			c = cin.get();
			if( cin.eof() ) return 0;
			if( c == '\n') break;
			else s += c;
		}

		cout << DoctorLovedEncode( s ) << endl;
	}
	return 0;
}