#include <iostream>
#include <string>
using namespace std;

int main() {

  char in;
  string wd = " ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string bd[32] = { "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 od = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";

  string input;

  while( true ) {
    if ( cin.eof() ) break;
    getline( cin, input );

    string k = "";

    for( int l = 0; l < input.size(); l++ ) {
      in = input[l];
      for ( int i = 0; i < 32; i++ ) {
	if ( in == wd[i] ) {
	  k += bd[i];
	  //	cout << bd[i];
	  if ( k.size() >= 5 ) {
	    int x = 0;
	    for ( int j = 0; j < 5; j++ ) {
	      x = x * 2 + k[j] - '0';
	    }
	    cout << od[x];
	    string n = "";
	    for ( int j = 5; j < k.size(); j++ ) {
	      n += k[j];
	    }
	    k = n;
	  }
	}
      }

    }
    if ( k.size() > 0 ) {
      k += "00000";
      int x = 0;
      for ( int j = 0; j < 5; j++ ) {
	x = x * 2 + k[j] - '0';
      }
      cout << od[x];
    }
    cout << endl;

  }

  return 0;

}