#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	char s[1024] = "", b[6];
	//t:before; u:after
	char t[32][9] = {"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", "101", "010001", "000011",
		"10010001", "000000", "000001"};
	char u[32][6] = {"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"};
	int i, j, c;
	while (cin.getline(s, sizeof(s)), !cin.eof())
	{
		char a[5120] = "", r[5120] = "";
		c = 0;
		for (i = 0; i < strlen(s); i++)
		{
			switch (s[i])
			{
			case ' ':
				for (j = 0; j < 3; j++, c++)
					a[c] = t[26][j];
				break;
			case '.':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[27][j];
				break;
			case ',':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[28][j];
				break;
			case '-':
				for (j = 0; j < 8; j++, c++)
					a[c] = t[29][j];
				break;
			case '\'':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[30][j];
				break;
			case '?':
				for (j = 0; j < 6; j++, c++)
					a[c] = t[31][j];
				break;
			default:
				for (j = 0; j < strlen(t[s[i]-'A']); j++, c++)
					a[c] = t[s[i]-'A'][j];
			}
		}
		for (i = c = 0; i < strlen(a); i += 5, c++)
		{
			for (j = 0; j < 5; j++)
			{
				if (a[i+j] != '\0')
					b[j] = a[i+j];
				else
					b[j] = '0';
			}
			b[5] = '\0';
			for (j = 0; j < 32; j++)
			{
				if (strcmp(b, u[j]) == 0)
				{
					switch (j)
					{
					case 26:
						r[c] = ' ';
						break;
					case 27:
						r[c] = '.';
						break;
					case 28:
						r[c] = ',';
						break;
					case 29:
						r[c] = '-';
						break;
					case 30:
						r[c] = '\'';
						break;
					case 31:
						r[c] = '?';
						break;
					default:
						r[c] = j + 'A';
					}
				}
			}
		}
		r[c+1] = '\0';
		cout << r << endl;
	}
}