program ProblemA;

{$APPTYPE CONSOLE}

const
  MaxN = 200;

var
  i, n: integer;
  a1, b1: array ['A'..'Z'] of integer;
  mar: array ['A'..'Z'] of char;
  s1, s2: string;
  ch, ch2: char;
  right, found: boolean;

begin
  assign(input, 'ancient.in');
  reset(input);
  assign(output, 'ancient.out');
  rewrite(output);
  readln(s1);
  readln(s2);
  n := length(s1);
  for i := 1 to n do
  begin
    inc(a1[s1[i]]);
    inc(b1[s2[i]]);
  end;
  right := true;
  for ch := 'A' to 'Z' do
  if a1[ch] > 0 then
  begin
    found := false;
    for ch2 := 'A' to 'Z' do
    if mar[ch2] = #0 then
    if b1[ch2] = a1[ch] then
    begin
      found := true;
      break;
    end;
    if not found then
    begin
      right := false;
      break;
    end;
  end;
  if right then
    write('YES')
  else
    write('NO');
end.
