#include <iostream>
#include <map>

using namespace std;

int main(void){
  string s;
  map<string,char> table1;
  map<char,string> table2;
  for(char c='A';c<='Z';++c){
    int a = c-'A';
    string key;
    for(int j=0;j<5;++j){
      key = ((a%2)?'1':'0') + key;
      a/=2;
    }
    table1[key]=c;
  }
  table1["11010"]=' ';
  table1["11011"]='.';
  table1["11100"]=',';
  table1["11101"]='-';
  table1["11110"]='\'';
  table1["11111"]='?';
  
  table2[' ']="101";
  table2['\'']="000000";
  table2[',']="000011";
  table2['-']="10010001";
  table2['.']="010001";
  table2['?']="000001";
  table2['A']="100101";
  table2['B']="10011010";
  table2['C']="0101";
  table2['D']="0001";
  table2['E']="110";
  table2['F']="01001";
  table2['G']="10011011";
  table2['H']="010000";
  table2['I']="0111";
  table2['J']="10011000";
  table2['K']="0110";
  table2['L']="00100";
  table2['M']="10011001";
  table2['N']="10011110";
  table2['O']="00101";
  table2['P']="111";
  table2['Q']="10011111";
  table2['R']="1000";
  table2['S']="00110";
  table2['T']="00111";
  table2['U']="10011100";
  table2['V']="10011101";
  table2['W']="000010";
  table2['X']="10010010";
  table2['Y']="10010011";
  table2['Z']="10010000";
  
  while(getline(cin,s),!cin.eof()){
    string encoded,result;
    for(int i=0;i<s.size();++i){
      encoded+=table2[s[i]];
    }
    string tmp;
   while(encoded.length()%5 != 0)encoded+="0";
    //cerr<<encoded<<endl;
    for(int i=0;i<encoded.size();++i){
      tmp += encoded[i];
      if(table1.find(tmp) != table1.end()){
        result+=table1[tmp];
        tmp="";
      }
    }
    cout<<result<<endl;
  }
  return 0;
}