import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    var S = sc.next.toBuffer
    val T = sc.next

    for (i <- S.indices if S(i) != T(i)) {
      val s = S(i)
      val t = T(i)
      S = S.map(c => if (c == s) t else if (c == t) s else c)
    }

    if (S.mkString == T) "Yes" else "No"
  }
}
