#include <cstdio>
#include <cstring>
#include <iostream>


using namespace std;

int to_int(char* numStr, int digits)
{
	const char* n = "0123456789abcdefghijklmnopqrstuvwxyz";
	int res = 0;
	for (int i = 0; numStr[i] != '\0'; ++i)
	{
		int j;
		for (j = 0; numStr[i] != n[j]; ++j)
			;
		res = res*digits + j;
	}
	return res;
}

char buf[2048];
char codeBuf[2048*5];
char enc[2048];

int main()
{
	const char* ori = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	const char* code[] = { "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* reEnc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

	while (!cin.eof())
	{
		cin.getline(buf, sizeof(buf));
		if (cin.eof())
			break;

		codeBuf[0] = '\0';
		for (int i = 0; buf[i] != '\0'; ++i)
		{
			int p;
			for (p = 0; buf[i] != ori[p]; ++p)
				;
			strcat(codeBuf, code[p]);
		}
		while (strlen(codeBuf) % 5 != 0)
			strcat(codeBuf, "0");

		int k = 0;
		for (int i = 0; i < (int)strlen(codeBuf); i += 5)
		{
			char w[6];
			for (int j = 0; j < 5; ++j)
				w[j] = codeBuf[i+j];
			w[5] = '\0';
			enc[k++] = reEnc[to_int(w, 2)];
		}
		enc[k] = '\0';

		printf("%s\n", enc);
	}

	return 0;
}