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

using namespace std;

string DoctorTableAD(char c){
	string s;
	switch( c ){
		case ' ': s = "101"; break;
		case 0x27: s = "000000"; break;
		case ',': s = "000011"; break;
		case '-': s = "10010001"; break;
		case '.': s = "010001"; break;
		case '?': s = "000001"; break;
		case 'A': s = "100101"; break;
		case 'B': s = "10011010"; break;
		case 'C': s = "0101"; break;
		case 'D': s = "0001"; break;
		case 'E': s = "110"; break;
		case 'F': s = "01001"; break;
		case 'G': s = "10011011"; break;
		case 'H': s = "010000"; break;
		case 'I': s = "0111"; break;
		case 'J': s = "10011000"; break;
		case 'K': s = "0110"; break;
		case 'L': s = "00100"; break;
		case 'M': s = "10011001"; break;
		case 'N': s = "10011110"; break;
		case 'O': s = "00101"; break;
		case 'P': s = "111"; break;
		case 'Q': s = "10011111"; break;
		case 'R': s = "1000"; break;
		case 'S': s = "00110"; break;
		case 'T': s = "00111"; break;
		case 'U': s = "10011100"; break;
		case 'V': s = "10011101"; break;
		case 'W': s = "000010"; break;
		case 'X': s = "10010010"; break;
		case 'Y': s = "10010011"; break;
		case 'Z': s = "10010000"; break;
	}
	return s;
}
int myatoi(string bin_s){
	int ret = 0;
	while( bin_s.length() > 0 ){
		ret += (int)((bin_s[0] - '0') * pow(2.0, (double)(bin_s.length() - 1)));
		bin_s.erase(0,1);
	}
	return ret;
}
char DoctorTableDA(string &s){
	int d = myatoi(s);
	char ac[] = " .,-'?";
	
	for(int i = 0; i < 'Z' - 'A'; 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;
}