#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <queue>
#include <cmath>
#include <stack>
#include <map>

#define int64 long long int 
using namespace std;

string encode(string, char);
string decode(string);

int main()
{
	int c, first, second;
	string str;

	second = 0;
	while((c = getchar()) != EOF){
		first = second, second = c;
		if(!(first == '\n' && second == EOF))
			str = encode(str, first);
	}
	cout << decode(str) << endl;

	return 0;
}

string decode(string str)
{
	int i, len, r;
	string part, ret;
	const string code[32] = {
		"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111",
		"01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111",
		"10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111",
		"11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111"
	};
	const string ch[35] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ",".",",","-","'","?"};

	len = str.size();

	for(i=0; i<len / 5; i++){
		part = str.substr( 5*i, 5 );
		for(int j=0; j<32; j++)
			if(part == code[j]){
				if(ret.empty()) ret = ch[j];
				else ret += ch[j];
			}
	}
	if((r = len % 5) != 0){
		part = str.substr( 5*i, len-1 );
		for(i=0; i<5-r; i++) part += "0";
		for(i=0; i<32; i++)
			if(part == code[i]) ret += ch[i];
	}
	return ret;
}

string encode(string str, char c)
{
	const string code[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"
	};
	const char ch[35] = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 

	for(int i=0; i<32; i++){
		if(c == ch[i]){
			if(str.empty()) str = code[i];
			else str += code[i];
		}
	}
	return str;
}