{$APPTYPE CONSOLE}
var
a,b:string;
c,d,e,f:array[1..27] of integer;
l1,l2,i,j,k,t:integer;
bool:boolean;
begin
assign(input,'ancient.in');
assign(output,'ancient.out');
reset(input);
rewrite(output);
readln(a);
readln(b);
l1:=length(a);
for i:=1 to l1-1 do
begin
for j:=i+1 to l1 do
  if a[i]=a[j] then
        begin
        c[i]:=c[i]+1;
        a[j]:='*';
        end;
end;
l2:=length(b);
for i:=1 to l2-1 do
for j:=i+1 to l2 do
  if b[i]=b[j] then
        begin
        d[i]:=d[i]+1;
        b[j]:='*';
        end;
k:=0;
for i:=1 to 26 do
        if c[i]<>0 then
                begin
                  inc(k);
                  e[k]:=c[i];
                end;
k:=0;
for i:=1 to 26 do
        if d[i]<>0 then
                begin
                  inc(k);
                  f[k]:=d[i];
                end;

for i:=1 to l1-1 do
  for j:=i+1 to l1 do
    if e[i]<e[j] then
     begin
          t:=e[i];
            e[i]:=e[j];
            e[j]:=t;
     end;

for i:=1 to l2-1 do
  for j:=i+1 to l2 do
    if f[i]<f[j] then
     begin
          t:=f[i];
            f[i]:=f[j];
            f[j]:=t;
     end;

bool:=true;
for i:=1 to 26 do
if e[i]<>f[i] then bool:=false;
if bool and (l1=l2) then write('YES')
else write('NO');
close(input);
close(output);
end.
