const mask = (s) => {
  let m = []
  let cnt = 0
  let map = {}
  s.split("").map((c) => {
    if (!map[c]) {
      map[c] = cnt
      cnt++
    }
    m.push(map[c])
  })
  return m
}
const solve = (s, t) => {
  return mask(s).join("-") === mask(t).join("-") ? "Yes" : "No"
}
const main = (input) => {
  const n = input.split("\n")
  const [s, t] = input.split("\n")
  return solve(s, t)
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}