program xx;
const inp='ancient.in';
     outp='ancient.out';
var i:longint;
    a,b:array['A'..'Z']of longint;
    d,e:array[0..10000]of longint;
    c:char;
    s1,s2:string;
begin
 assign(input,inp); reset(input);
 assign(output,outp); rewrite(output);
 readln(s1);
 readln(s2);
 fillchar(a,sizeof(a),0);
 fillchar(b,sizeof(b),0);
 fillchar(d,sizeof(d),0);
 fillchar(e,sizeof(e),0);

 for i:=1 to length(s1) do inc(a[s1[i]]);
 for i:=1 to length(s2) do inc(b[s2[i]]);
for c:='A' to 'Z' do inc(d[a[c]]);
for c:='A' to 'Z' do inc(e[b[c]]);
s1:='YES';
 for i:=0 to 10000 do
  if d[i]<>e[i] then s1:='NO';
 writeln(s1);
 close(input); close(output);
end.
