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);

  bool[] flag = new bool[26];

  foreach(i; 0..S.length) {
    if (S[i] == T[i]) {
      flag[S[i]-'a'] = true;
    }
  }

  foreach(i; 0..S.length) {
    if (S[i] != T[i]) {
      if (flag[S[i]-'a'] || flag[T[i]-'a']) {
        writeln("No");
        return;
      }
    }
  }

  writeln("Yes");
}

// 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..$];
  }
}
