var
  s1, s2: string;
  t, n1, n2, i, j: integer;
  c1, c2: array[1..200] of integer;
  w: array['A'..'Z'] of integer;
  ch: char;

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

  readln(s1);
  readln(s2);

  fillchar(w, sizeof(w), 0);
  for i := 1 to length(s1) do
    inc(w[s1[i]]);
  
  n1 := 0;
  for ch := 'A' to 'Z' do
    if w[ch] > 0 then begin
      inc(n1);
      c1[n1] := w[ch];
    end;

  fillchar(w, sizeof(w), 0);
  for i := 1 to length(s2) do
    inc(w[s2[i]]);
  
  n2 := 0;
  for ch := 'A' to 'Z' do
    if w[ch] > 0 then begin
      inc(n2);
      c2[n2] := w[ch];
    end;

  if n1 <> n2 then begin
    writeln('NO');
    halt;
  end;

  for i := 1 to n1 - 1 do
    for j := i + 1 to n1 do
      if c1[i] > c1[j] then begin
         t := c1[i];
         c1[i] := c1[j];
         c1[j] := t;
      end;

  for i := 1 to n1 - 1 do
    for j := i + 1 to n1 do
      if c2[i] > c2[j] then begin
         t := c2[i];
         c2[i] := c2[j];
         c2[j] := t;
      end;

  i := 1;
  while (i <= n1) and (c1[i] = c2[i]) do
    inc(i);
 
  if i > n1 then
    writeln('YES')
  else
    writeln('NO');
end.
