module CharSet = Set.Make (Char)

let () =
  let s = read_line () in
  let t = read_line () in
  let a = Array.make 26 CharSet.empty in
  let ix c = Char.code c - Char.code 'a' in
  for i = 0 to String.length s - 1 do
    if s.[i] <> t.[i] then begin
      a.(ix s.[i]) <- CharSet.add t.[i] a.(ix s.[i]);
      a.(ix t.[i]) <- CharSet.add s.[i] a.(ix t.[i])
    end
  done;
  print_endline @@
  if
    List.for_all (fun l -> CharSet.cardinal l <= 2) @@
    Array.to_list a
  then "Yes"
  else "No"
