#include <iostream>
#include <cstring>
using namespace std;

int main() {
	char code[32][15] = {
		"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"
	};
	int coden[255];
	char tmp[33] = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for (int i = 0; i < 32; i++) {
		coden[tmp[i]] = i;
	}
	char str[100];
	int makedcode[1500];
	int count;

	while (gets(str) != NULL) {
		count = 0;
		for (int i = 0, slen = strlen(str); i < slen; i++) {
			for (int j = 0, clen = strlen(code[coden[str[i]]]); j < clen; j++) {
				makedcode[count++] = code[coden[str[i]]][j] - '0';
			}
		}
		for (int i = 0, j = 0, sum;; i++, j++) {
			if (j == 5) {
				if ('a' - 'a' <= sum && sum <= 'z' - 'a')
					cout << (char)(sum + 'A');
				else {
					char c;
					switch (sum) {
					case 26:
						c = ' '; break;
					case 27:
						c = '.'; break;
					case 28:
						c = ','; break;
					case 29:
						c = '-'; break;
					case 30:
						c = '\''; break;
					case 31:
						c = '?'; break;
					}
					cout << c;
				}
				if (i >= count)
					break;
				j = 0;
			}
			if (j == 0)
				sum = 0;
			if (i < count)
				sum = (sum << 1) + makedcode[i];
			else
				sum = sum << 1;
		}
		cout << endl;
	}
	return 0;
}