var
  a, b: array ['A'..'Z'] of longint;
  c, d: array [0..100] of longint;
  st: string;
  i, l: longint;
  j: char;
  bool: boolean;

begin
  bool := false;
  fillchar(a, sizeof(a), 0);
  fillchar(b, sizeof(b), 0);
  fillchar(c, sizeof(c), 0);
  fillchar(d, sizeof(d), 0);
  assign(input, 'ancient.in');
  assign(output, 'ancient.out');
  reset(input);
  rewrite(output);
  readln(st);
  l := length(st);  
  for i := 1 to l do
    inc(a[st[i]]);
  readln(st);
  for i := 1 to l do
    inc(b[st[i]]);
  for j := 'A' to 'Z' do
    inc(c[a[j]]);
  for j := 'A' to 'Z' do
    inc(d[b[j]]);
  for i := 1 to l do
    if c[i] <> d[i] then
    begin
      bool := true;
      break;
    end;
  if bool then
    write('NO')
  else
    write('YES');
  close(input);
  close(output);
end.