Code = {" " => "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"
}
Codew = (("A".."Z").to_a + [" ", ".", ",", "-", "'", "?"]).map.with_index{|v,i|[v, i.to_s(2).rjust(5, "0")]}.to_h
class BinTree
  def self.root=(val)
    @@root = val
  end
  @@root
  attr_accessor :root
  def initialize
    @value = nil
    @children = nil
  end

  def search(bin)
    if bin == ""
      return @value
    else
      return @children[bin[0].to_i].search(bin[1..-1])
    end
  end

  def insert(bin, v)
    if bin == ""
      @value = v
    elsif @children
      @children[bin[0].to_i].insert(bin[1..-1], v)
    else
      @children = [BinTree.new, BinTree.new]
      insert(bin, v)
    end
  end

  def decode(str)
    if @value
      return @value + @@root.decode(str)
    elsif str == "" or !@children
      return ""
    else
      return @children[str[0].to_i].decode(str[1..-1])
    end
  end
end
root = BinTree.new
BinTree.root = root
Code.each {|(key,value)|root.insert(value, key)}
str = gets.chomp.split(//).map{|i|Codew[i]}.join
#p str
puts root.decode(str)