program A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
        s1,s2:string;
        x1,x2:array[1..100] of integer;
        y1,y2:array[1..100] of boolean;
        sum,i,j,k,n,am1,am2:integer;
        res:boolean;
begin
  assignFile(input,'ancient.in'); Reset(input);
  assignFile(output,'ancient.out'); Rewrite(output);
  for i:=1 to 100 do
  begin
        x1[i]:=0;x2[i]:=0;y1[i]:=false;y2[i]:=false;
  end;
  am1:=0;am2:=0;

  readln(s1);readln(s2);
  n:=length(s1);

  for i:=1 to n do
        if y1[i]=false then
                begin
                        sum:=0;
                        for j:=i to n do
                                if s1[j]=s1[i] then
                                        begin
                                        inc(sum);
                                        y1[j]:=true;
                                        end;
                        inc(am1);x1[am1]:=sum;
                end;
    for i:=1 to n do
        if y2[i]=false then
                begin
                        sum:=0;
                        for j:=i to n do
                                if s2[j]=s2[i] then
                                        begin
                                        inc(sum);
                                        y2[j]:=true;
                                        end;
                        inc(am2);x2[am2]:=sum;
                end;

For i:=1 to am1 do
For j:=1 to am1-1 do
If X1[j]<X1[j+1] then Begin
  k:=X1[j]; X1[j]:=X1[j+1]; X1[j+1]:=k;
End;

For i:=1 to am2 do
For j:=1 to am2-1 do
If X2[j]<X2[j+1] then Begin
  k:=X2[j]; X2[j]:=X2[j+1]; X2[j+1]:=k;
End;



res:=true;
if (am1<>am2) then
        begin
                res:=false;
        end
        else
        begin
                for i:=1 to am1 do
                        begin
                                if x1[i]<>x2[i] then res:=false;
                        end
        end;
if (res=true) then
        writeln('YES')
        else
        writeln('NO');
end.
