#include <iostream>
#include <cstdio>
#define P pair<int,int>
using namespace std;
P tbl[] = {
  P(3,0x5),P(6,0),P(6,0x3),P(8,0x91),P(6,0x11),P(6,0x1),P(6,0x25),P(8,0x9a),
  P(4,0x5),P(4,0x1),P(3,0x6),P(5,0x9),P(8,0x9b),P(6,0x10),P(4,0x7),P(8,0x98),
  P(4,0x6),P(5,0x4),P(8,0x99),P(8,0x9e),P(5,0x5),P(3,0x7),P(8,0x9f),P(4,0x8),
  P(5,0x6),P(5,0x7),P(8,0x9c),P(8,0x9d),P(6,0x2),P(8,0x92),P(8,0x93),P(8,0x90),
};
char tbl2[] = { ' ', '.', ',', '-', '\'', '?' }; 
int main()
{
  char c,a;
  int b = 0,d = 0;
  P p;
  while(scanf("%c",&c) != EOF){
    if(c == '\n'){
      a = (d << (5 - b)) & 0x1f;
      if(a <= 26) printf("%c", a+'A');
      else printf("%c", tbl2[a-26]);
      cout << endl;
    }else{
      switch(c){
      case ' ': p = tbl[0]; break;
      case '\'': p = tbl[1]; break;
      case ',': p = tbl[2]; break;
      case '-': p = tbl[3]; break;
      case '.': p = tbl[4]; break;
      case '?': p = tbl[5]; break;
      default: p = tbl[c-'A'+6]; break;
      }
      b += p.first;
      d = (d << p.first) | p.second;
      if(b >= 5){
	a = (d >> (b-5)) & 0x1f;
	if(a <= 26) printf("%c", a+'A');
	else printf("%c", tbl2[a-26]);
	b -= 5;
      }
    }
  }
  return 0;
}