var
   st,st1               :string;
   size,size1,i,j       :integer;
   test,test1           :boolean;
   values,values1       :array[1..101]of integer;
   chars,chars1         :array[1..101]of char;
   temp                 :integer;
procedure readfile;
begin
   assign(input,'ancient.in');
   assign(output,'ancient.out');
   reset(input);
   rewrite(output);
   readln(st);
   read(st1);
end;
procedure make;
begin
   size:=0;
   for i:=1 to length(st) do
   begin
      test:=false;
      for j:=1 to size do
      begin
         if chars[j]=st[i] then
         begin
            values[j]:=values[j]+1;
            test:=true;
         end;
      end;
      if test=false then
      begin
         inc(size);
         chars[size]:=st[i]
      end;
   end;

   size1:=0;
   for i:=1 to length(st1) do
   begin
      test1:=false;
      for j:=1 to size1 do
      begin
         if chars1[j]=st1[i] then
         begin
            values1[j]:=values1[j]+1;
            test1:=true;
         end;
      end;
      if test1=false then
      begin
         inc(size1);
         chars1[size1]:=st1[i]
      end;
   end;

end;
begin
   readfile;
   make;
   for i:=size-1 downto 1 do
   begin
      for j:=1 to i do
      begin
         if values[j]>values[j+1]then
         begin
            temp:=values[j+1];
            values[j+1]:=values[j];
            values[j]:=temp;
         end;
         if values1[j]>values1[j+1]then
         begin
            temp:=values1[j+1];
            values1[j+1]:=values1[j];
            values1[j]:=temp;
         end;
      end;
   end;
   test:=true;
   for i:=1 to size do
   begin
      if values[i]<>values1[i] then
      begin
         test:=false;
         break;
      end;
   end;
   if test=true then write('YES') else write('NO');
   close(input);
   close(output);
end.
