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

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  string t; readV(t);

  auto vs = conv(s), vt = conv(t);
  if (!equal(vs, vt)) {
    writeln("No");
    return;
  }

  writeln("Yes");
}

auto conv(string s)
{
  auto c = new int[](s.length);
  int[int] h;
  foreach (i, si; s) {
    auto j = cast(int)(si-'a');
    if (j !in h) h[j] = h.length.to!int;
    c[i] = h[j];
  }
  return c;
}
