import std.stdio, std.conv, std.string, std.algorithm,
       std.math, std.array, std.container, std.typecons;

int[] maps = new int[256];
int[] mapt = new int[256];
int sn = 1, tn = 1;

bool check(char sc, char tc) {
  if(maps[sc]==0) maps[sc] = sn++;
  if(mapt[tc]==0) mapt[tc] = tn++;
  return maps[sc]==mapt[tc];
}

bool solve() {
  auto s = readln.chomp;
  auto t = readln.chomp;
  for(int i=0; i<s.length; i++) if(!check(s[i], t[i])) return false;
  return true;
}

void main() {
  if(solve()) writeln("Yes");
  else writeln("No");
}
