{$apptype console}
{ $q+,r+,o-}
{$q+,r+,o+}
{ $q-,r-,o+}

uses
  math, sysutils;

type
  int = longint;
  bool = boolean;
  float = extended;

const
  fn = 'ancient';

procedure sort(var s : string);
var
  a : array['A'..'Z'] of int;
  i : int;
  c : char;
begin
  fillchar(a, sizeof(a), 0);
  for i := 1 to length(s) do begin
    inc(a[s[i]]);
  end;
  s := '';
  for i := 105 downto 0 do begin
    for c := 'A' to 'Z' do begin
      if a[c] = i then begin
        while a[c] > 0 do begin
          dec(a[c]);
          s := s + c;
        end;
      end;
    end;
  end;
end;

var
  s1, s2 : string;
  i : int;
  a : array[#0..#255] of char;
  b : array[#0..#255] of char;

begin
  reset(input, fn + '.in');
  rewrite(output, fn + '.out');

  readln(s1);
  readln(s2);
  s1 := trim(uppercase(s1));
  s2 := trim(uppercase(s2));

  sort(s1);
  sort(s2);

  assert(length(s1) = length(s2));

  fillchar(a, sizeof(a), #0);
  fillchar(b, sizeof(b), #0);

  for i := 1 to length(s1) do begin
    if a[s1[i]] = #0 then begin
      a[s1[i]] := s2[i];
    end else begin
      if a[s1[i]] <> s2[i] then begin
        writeln('NO');
        halt;
      end;
    end;
    if b[s2[i]] = #0 then begin
      b[s2[i]] := s1[i];
    end else begin
      if b[s2[i]] <> s1[i] then begin
        writeln('NO');
        halt;
      end;
    end;
  end;

  writeln('YES');
end.
