{$apptype console}

var
  a, b: array['A'..'Z'] of integer;
  s: string;
  i: integer;
  c1, c2, m: char;
  f: boolean;
begin
  Assign(input, 'ancient.in');
  Assign(output, 'ancient.out');
  Reset(input);
  Rewrite(output);
  FillChar(a, SizeOf(a), 0);
  FillChar(b, SizeOf(b), 0);
  Readln(s);
  for i := 1 to Length(s) do
    Inc(a[s[i]]);
  Readln(s);
  for i := 1 to Length(s) do
    Inc(b[s[i]]);
  for c1 := 'A' to 'Y' do begin
    m := c1;
    for c2 := Chr(Ord(c1) + 1) to 'Z' do
      if (a[c2] > a[m]) then
        m := c2;
    i := a[c1];
    a[c1] := a[m];
    a[m] := i;
  end;
    
  for c1 := 'A' to 'Y' do begin
    m := c1;
    for c2 := Chr(Ord(c1) + 1) to 'Z' do
      if (b[c2] > b[m]) then
        m := c2;
    i := b[c1];   
    b[c1] := b[m];
    b[m] := i;
  end;
  f := true;
  for c1 := 'A' to 'Z' do
    if (a[c1] <> b[c1]) then
      f := false;
  if f then
    Writeln('YES')
  else
    Writeln('NO');

  Close(input);
  Close(output);
end.