void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  auto s = readln.chomp.to!(char[]);
  auto t = readln.chomp.to!(char[]);

  int[char] f1, f2;
  foreach (c; s) {
    if (c in f1)
      f1[c]++;
    else
      f1[c] = 1;
  }
  foreach (c; t) {
    if (c in f2)
      f2[c]++;
    else
      f2[c] = 1;
  }
  int[] a, b;
  foreach (cnt; f1)
    a ~= cnt;
  foreach (cnt; f2)
    b ~= cnt;

  if (a.length != b.length) {
    writeln("No");
    return;
  }
  sort(a);
  sort(b);
  bool ok = true;
  foreach (i; 0 .. a.length) {
    ok &= a[i] == b[i];
  }
  writeln(ok ? "Yes" : "No");
}

void rd(T...)(ref T x) {
  import std.stdio, std.string, std.conv;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}
