program task1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  l,k1,k2,i,j,k:longint;
  st1,st2:string;
  a1,a2:array['A'..'Z']of longint;
  b1,b2:array[1..1000]of longint;
  ch:char;
  f:boolean;
begin
assign(input,'ancient.in');reset(input);
assign(output,'ancient.out');rewrite(output);
readln(st1);
readln(st2);
for i:=1 to length(st1) do inc(a1[st1[i]]);
for i:=1 to length(st2) do inc(a2[st2[i]]);
for ch:='A' to 'Z' do
if a1[ch]<>0 then
begin
  inc(k1);
  b1[k1]:=a1[ch];
end;
for ch:='A' to 'Z' do
if a2[ch]<>0 then
begin
  inc(k2);
  b2[k2]:=a2[ch];
end;
for i:=1 to k1-1 do
begin
  k:=i;
  for j:=i+1 to k1 do
    if b1[k]>b1[j] then k:=j;
  l:=b1[k];
  b1[k]:=b1[i];
  b1[i]:=l;
end;
for i:=1 to k1-1 do
begin
  k:=i;
  for j:=i+1 to k1 do
    if b2[k]>b2[j] then k:=j;
  l:=b2[k];
  b2[k]:=b2[i];
  b2[i]:=l;
end;

if k1<>k2 then writeln('NO') else
begin
  f:=true;
  for i:=1 to k1 do
    if b1[i]<>b2[i] then f:=false;
  if f then writeln('YES') else writeln('NO');  
end;

close(output);
close(input);
end.
 