#include <iostream>
#include <string>

using namespace std;

string letter_to_sign[35] = {

  "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"

};

string sign_to_letter[35] = {

  "A","B","C","D","E","F","G","H",
  "I","J","K","L","M","N","O","P",
  "Q","R","S","T","U","V","W","X",
  "Y","Z"," ",".",",","-","\'","?"

};

int main() {

  string buf;

  string str;
  string ans;

  int l;


  while(getline(cin,buf)) {

    str="";

    for(int i=0;i<(int)buf.length();i++) {

      if(buf[i]==' ') str+=letter_to_sign[0];

      else if(buf[i]=='\'') str+=letter_to_sign[1];

      else if(buf[i]==',') str+=letter_to_sign[2];

      else if(buf[i]=='-') str+=letter_to_sign[3];

      else if(buf[i]=='.') str+=letter_to_sign[4];

      else if(buf[i]=='?') str+=letter_to_sign[5];

      else str+=letter_to_sign[buf[i]-'A'+6];

    }

    l=str.length();

    for(int i=0;i<5-l%5;i++) str+="0";

    cout << str << endl;

    l=str.length();

    ans="";

    for(int i=0;i<l;i=i+5) {

      int index;

      index=16*(str[i]-'0')+8*(str[i+1]-'0')+4*(str[i+2]-'0')+2*(str[i+3]-'0')+(str[i+4]-'0');

      ans+=sign_to_letter[index];

    }

    cout << ans << endl;

  }

  return 0;

}