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

std::string enc[] = { "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" };
std::string str = " \',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
std::string symbol = " .,-\'?";

int bin( std::string s )
{
	std::reverse( s.begin(), s.end() );

	int ret = 0, w = 1;
	for( int i = 0; i != s.size(); ++i )
	{
		if( s[i] - '0' )
			ret += w;

		w <<= 1;
	}

	return ret;
}

int main()
{
	std::string s;
	while( std::getline( std::cin, s ) )
	{
		std::string code;
		for( int i = 0; i != s.size(); ++i )
			code += enc[ str.find( s[i] ) ];

		for( int i = 0; i < code.size(); i += 5 )
		{
			std::string t = code.substr( i, std::min( 5, (int)code.size() - i ) ) + std::string( std::max( 0, 5 - (int)code.size() + i ), '0' );
			int n = bin( t );
			std::cout << ( n + 6 < str.size() ? str[n + 6] : symbol[n + 6 - str.size()] );
		}

		std::cout << std::endl;
	}

	return 0;
}