{$APPTYPE CONSOLE}
{$O-,R+,Q+}
uses
  Sysutils, Math;
const
  inf = 1000000000;
  eps = 1e-9;
  base = 10;
type
  int = longint;
  bool = boolean;
  real = extended;
var
  i, j, k, n, m: int;
  num, num1: array['A'..'Z'] of int;
  st1, st2: string;
  b,c : char;
  fl: bool;
  
procedure check;
var
  ch: char;
  fl: bool;
begin
  fl := true;
  for ch := 'A' to 'Z' do
  begin
    if num[ch] <> num1[ch] then
    begin
      fl := false;
      break;
    end;
  end;

  if fl then
  begin
    writeln('YES');
    halt(0);
  end;
end;

function shift(ch: char): char;
begin
  if ch = 'Z' then result := 'A'
  else begin
    result := chr(ord(ch) + 1);
  end;
end;

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

  readln(st1);
  readln(st2);
  fillchar(num1, sizeof(num1), 0);
  for i := 1 to length(st2) do
  begin
    inc(num1[st2[i]]);
  end;
  fillchar(num, sizeof(num), 0);
  for j := 1 to length(st1) do
  begin
    inc(num[st1[j]]);
  end;

  for c := 'A' to 'Z' do
  begin
    for b := 'A' to 'Z' do
    begin
      if num1[c] > num1[b] then
      begin
        j := num1[c];
        num1[c] := num1[b];
        num1[b] := j;
      end;
    end;
  end;

  for c := 'A' to 'Z' do
  begin
    for b := 'A' to 'Z' do
    begin
      if num[c] > num[b] then
      begin
        j := num[c];
        num[c] := num[b];
        num[b] := j;
      end;
    end;
  end;
  fl := true;
  for c := 'A' to 'Z' do
  begin
    if num1[c] <> num[c] then
    begin
      fl := false;
      break;
    end;
  end;
  if fl then
  begin
    writeln('YES');
  end else
  begin
    writeln('NO');
  end;
{  for i := 1 to 26 do
  begin
    for j := 1 to length(st1) do
    begin
      st1[j] := shift(st1[j]);
    end;
    fillchar(num, sizeof(num), 0);
    for j := 1 to length(st1) do
    begin
      inc(num[st1[j]]);
    end;
    check;
  end;
  writeln('NO');}
  close(input);
  close(output);
end.
//Leafy tops of root vegetables strike back...