program taskA;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s1, s2 : string;
  arr1, arr2 : array[char] of integer;
  i, t : integer;
  ch, ch1, ch2 : char;
  b : boolean;

begin
  assign( input, 'ancient.in' );
  assign( output, 'ancient.out' );
  reset(input);
  rewrite(output);

  readln(s1);
  readln(s2);

  for ch := 'A' to 'Z' do begin
    arr1[ch] := 0;
    arr2[ch] := 0;
  end;

  for i:=1 to length(s1) do
    inc(arr1[s1[i]]);

  for i:=1 to length(s2) do
    inc(arr2[s2[i]]);

  for ch1 := 'A' to 'Z' do
    for ch2 := 'A' to 'Y' do
      if arr2[ch2] > arr2[chr(ord(ch2)+1)] then begin
        t := arr2[ch2];
        arr2[ch2] := arr2[chr(ord(ch2)+1)];
        arr2[chr(ord(ch2)+1)] := t;
      end;

  for ch1 := 'A' to 'Z' do
    for ch2 := 'A' to 'Y' do
      if arr1[ch2] > arr1[chr(ord(ch2)+1)] then begin
        t := arr1[ch2];
        arr1[ch2] := arr1[chr(ord(ch2)+1)];
        arr1[chr(ord(ch2)+1)] := t;
      end;

  b := true;

  for ch := 'A' to 'Z' do
    if arr1[ch] <> arr2[ch] then
      b := false;

  if b then writeln('YES')
  else writeln('NO');


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

