import std.stdio;
import std.algorithm;
import std.range;
import std.conv;
import std.format;
import std.array;
import std.math;
import std.string;
import std.container;

void main() {
  string S, T;
  readlnTo(S);
  readlnTo(T);

  int[] a = new int[26];
  int[] b = new int[26];

  a.fill(-1);
  b.fill(-1);

  bool ok = true;
  foreach(i; 0..S.length) {
    auto s = S[i] - 'a';
    auto t = T[i] - 'a';

    if (a[s] >= 0) {
      ok = ok && (a[s] == t);
    }

    if (b[t] >= 0) {
      ok = ok && (b[t] == s);
    }

    if (a[s] < 0) a[s] = t;
    if (b[t] < 0) b[t] = s;
  }

  writeln(ok ? "Yes" : "No");
}

// helpers
void readlnTo(T...)(ref T t) {
  auto s = readln.split;
  assert(s.length == t.length);
  foreach(ref ti; t) {
    ti = s[0].to!(typeof(ti));
    s = s[1..$];
  }
}
