import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp.to!(char[]);
  auto t = readln.chomp.to!(char[]);
  bool[char] done;
  auto f = true;

  foreach (i; 0..s.length) {
    if (s[i] != t[i]) {
      if (done.get(s[i], true) && done.get(t[i], true)) {
        foreach (j; i+1..s.length) {
          if (s[j] == t[i]) {
            s[j] = s[i];
          } else if (s[j] == s[i]) {
            s[j] = t[i];
          }
        }
        s[i] = t[i];
      } else {
        f = false;
        break;
      }
    }
    done[s[i]] = false;
  }

  if (f) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}
