#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
const int MOD=100000;
string a[26]={"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"};
string b[26]={
      "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"
};
int main(){
      string s;
      while(getline(cin,s)){
            string t="";
            REP(i,s.size()){
                  if(s[i]==' ')t+="101";
                  else if(s[i]=='\'')t+="000000";
                  else if(s[i]==',')t+="000011";
                  else if(s[i]=='-')t+="10010001";
                  else if(s[i]=='.')t+="010001";
                  else{
                        REP(j,26){
                              if(s[i]==('A'+j))t+=a[j];
                        }
                  }
            }
            while(t.size()%5!=0)t+='0';
            //cout<<t<<endl;
            string ans="";
            REP(i,t.size()/5){
                  s.assign(t,i*5,5);
                  REP(j,26){
                        if(s==b[j]){
                              ans+=('A'+j);
                        }
                  }
                  if(ans.size()==i){
                        if(s=="11010")ans+=' ';
                        else if(s=="11011")ans+='.';
                        else if(s=="11100")ans+=',';
                        else if(s=="11101")ans+='-';
                        else if(s=="11110")ans+='\'';
                        else ans+='?';
                  }
                  //cout<<s<<endl;
            }
            cout<<ans<<endl;
      }
}