#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

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;
}

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

	while (!cin.eof())
	{
		char buf[512];
		char codeBuf[2048];
		cin.getline(buf, sizeof(buf));
		if (strlen(buf) == 0)
			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");

		char enc[512];
		int k = 0;
		for (int i = 0; i < 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;
}