import scala.io.StdIn.{readInt,readLine}

object Main {
  val codes = {for(i<-'A' to 'Z') yield i->("00000"+(i-65).toBinaryString).takeRight(5)}
          .toMap ++ Map(' '->"11010",'.'->"11011",','->"11100",'-'->"11101",'\''->"11110",'?'->"11111")

  val str = Map("101"->' ',"000000"->'\'', "000011"->',',
    "10010001"->'-',"010001"->'.',"000001"->'?',
    "100101"->'A',"10011010"->'B',"0101"->'C',"0001"->'D',
    "110"->'E',"01001"->'F',"10011011"->'G',"010000"->'H',
    "0111"->'I',"10011000"->'J',"0110"->'K',"00100"->'L',
    "10011001"->'M',"10011110"->'N',"00101"->'O',"111"->'P',
    "10011111"->'Q',"1000"->'R',"00110"->'S',"00111"->'T',
    "10011100"->'U',"10011101"->'V',"000010"->'W',"10010010"->'X',
    "10010011"->'Y',"10010000"->'Z')

  def scan(s:String,r:String):String = {
    def loop(i:Int):(String,String) = {
      if(i==9) (s,"")
      else{
        val s2 = s.take(i)
        if(str.contains(s2)) (s.drop(i),str(s2).toString)
        else loop(i+1)
      }
    }
    val x=loop(3)
    if(x._2!="") scan(x._1,r+x._2)
    else r
  }

  def main(args:Array[String]) = {
    val s = readLine.trim.map(codes(_)).mkString
    println(scan(s,""))
  }
}