#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
using namespace std;

int main() {
	char c[1000],st[8010],d[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","000000","000011","10010001","010001","000001"};
	int cn[256],i,j,k,p,n,a[6]={32,46,44,45,39,63};
    for (i=0;i<26;i++) cn[65+i]=i;
	cn[32]=26; cn[39]=27; cn[44]=28; cn[45]=29; cn[46]=30; cn[63]=31;
	while(gets(c)!=NULL) {
		p=0;
		for (i=0;i<strlen(c);i++) for (j=0;j<strlen(d[cn[(int)c[i]]]);j++) st[p++]=d[cn[(int)c[i]]][j];
		for (p;p % 5!=0;p++) st[p]='0';
		for (i=0;i<p;i+=5) {
         for (j=16,n=0,k=0;k<5;j/=2,k++) n+=j*(st[i+k]-'0');
		 if (n>=0 && n<=25) cout << (char)(65+n) ;
		 else  cout << (char)(a[n-26]);
		}
		cout << endl;
	}
    return 0;
}