object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s,t = sc.next
  var m1,m2 = Map[Char, Set[Char]]()
  s.zip(t).foreach{ case (c1,c2) =>
    m1 += c1 -> (m1.getOrElse(c1, Set()) + c2)
    m2 += c2 -> (m2.getOrElse(c2, Set()) + c1)
  }

  println(if ((m1.values ++ m2.values).forall(_.size == 1)) "Yes" else "No")
}