program ancient;

var
  S1, S2: String;
  Result: Boolean;
  A1, A2: array['A'..'Z'] of Integer;
  I: Integer;
  Ch, Ch2: Char;

begin
  Assign(Input, 'ancient.in');
  Assign(Output, 'ancient.out');
  Readln(S1);
  Readln(S2);
  FillChar(A1, SizeOf(A1), 0);
  FillChar(A2, SizeOf(A2), 0);
  for I := 1 to Length(S1) do
  begin
    Inc(A1[S1[I]]);
    Inc(A2[S2[I]]);
  end;
  for Ch := 'A' to 'Z' do
    if A1[Ch] > 0 then
    begin
      Ch2 := 'A';
      while (Ch2 <= 'Z') and (A2[Ch2] <> A1[Ch]) do Inc(Ch2);
      if Ch2 <= 'Z' then
      begin
        A1[Ch] := 0;
        A2[Ch2] := 0;
      end;
    end;
  Result := True;
  for Ch := 'A' to 'Z' do
    Result := Result and (A1[Ch] = 0) and (A2[Ch] = 0);
  if Result then Writeln('YES') else Writeln('NO');
end.
