T = {
  ' ' => '101',
  ?' => '000000',
  ?, => '000011',
  ?- => '10010001',
  ?. => '010001',
  ?? => '000001',
  ?A => '100101',
  ?B => '10011010',
  ?C => '0101',
  ?D => '0001',
  ?E => '110',
  ?F => '01001',
  ?G => '10011011',
  ?H => '010000',
  ?I => '0111',
  ?J => '10011000',
  ?K => '0110',
  ?L => '00100',
  ?M => '10011001',
  ?N => '10011110',
  ?O => '00101',
  ?P => '111',
  ?Q => '10011111',
  ?R => '1000',
  ?S => '00110',
  ?T => '00111',
  ?U => '10011100',
  ?V => '10011101',
  ?W => '000010',
  ?X => '10010010',
  ?Y => '10010011',
  ?Z => '10010000',
}.freeze
S = {
  0b00000 => ?A,
  0b00001 => ?B,
  0b00010 => ?C,
  0b00011 => ?D,
  0b00100 => ?E,
  0b00101 => ?F,
  0b00110 => ?G,
  0b00111 => ?H,
  0b01000 => ?I,
  0b01001 => ?J,
  0b01010 => ?K,
  0b01011 => ?L,
  0b01100 => ?M,
  0b01101 => ?N,
  0b01110 => ?O,
  0b01111 => ?P,
  0b10000 => ?Q,
  0b10001 => ?R,
  0b10010 => ?S,
  0b10011 => ?T,
  0b10100 => ?U,
  0b10101 => ?V,
  0b10110 => ?W,
  0b10111 => ?X,
  0b11000 => ?Y,
  0b11001 => ?Z,
  0b11010 => ' ',
  0b11011 => ?.,
  0b11100 => ?,,
  0b11101 => ?-,
  0b11110 => ?',
  0b11111 => ??,
}.freeze
$<.each_line do |l|
  s = ''
  l.chomp.each_char {|c| s << T[c] }
  s << ?0 * (5 - s.size % 5)
  puts s.each_char.each_slice(5).map {|a| S[a.join.to_i 2] }.join
end