#include <iostream>
#include <string>
using namespace std;

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

char getCode2( string& s ){
	char c = 0;
	for ( int i = 0; i < 5; ++i ){
		c += ( ( s[ 4 - i ] - '0' ) << i );
	}
	if ( c < 26 ){
		c += 'A';
	}else{
		switch( c ){
			case 26: c = ' '; break;
			case 27: c = '.'; break;
			case 28: c = ','; break;
			case 29: c = '-'; break;
			case 30: c = '\''; break;
			case 31: c = '?'; break;
		}
	}
	return c;
}

void firstEnc( string& is ){
	string os;
	string::iterator it = is.begin();
	while ( it != is.end() ){
		os += getCode1( *it );
		it = is.erase( it );
	}
	is = os;
}

void secondEnc( string& is ){
	string os;
	if ( is.size() % 5 ){
		is.append( 5 - is.size() % 5 , '0' );
	}
	while ( is.size() ){
		string set( is, 0, 5 );
		os += getCode2( set );
		is.erase( 0, 5 );
	}
	is = os;
}

int main(){
	string s;

	while ( getline( cin, s ) ){
		firstEnc( s );
		secondEnc( s );
		cout << s << endl;
	}
	return 0;
}