{$DEFINE DEBUG}

{$IFDEF DEBUG}
{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q+,R+,S+,T-,U-,V+,W-,X+,Y+,Z1}
{$ELSE}
{$A+,B-,C+,D-,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$ENDIF}

{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $02000000}
{$APPTYPE CONSOLE}

uses
  Math, SysUtils;

type
  int = longint;
  float = extended;

const
  maxn = 300;
  cin_file = 'ancient.in';
  cout_file = 'ancient.out';
  eps : float = 1e-9;
  fmax : float = 1e40;
  besk = $3F3F3F3F;
  alph = ['A'..'Z'];

var
  n1, n2 : int;
  a1, a2 : array[1..maxn] of int;
  ans : boolean;

procedure swap(var a, b : int);
var
  t : int;
begin
  t := a;
  a := b;
  b := t;
end;


procedure solve;
var
  i, j : int;
  s : string;
  tmp : array['A'..'Z'] of int;
  ch : char;
begin
  readln(s);
  fillchar(tmp, sizeof(tmp), 0);
  for i := 1 to length(s) do
    if (s[i] in alph) then inc(tmp[s[i]]);
  n1 := 0;
  for ch := 'A' to 'Z' do
  begin
    inc(n1);
    a1[n1] := tmp[ch];
  end;

  readln(s);
  fillchar(tmp, sizeof(tmp), 0);
  for i := 1 to length(s) do
    if (s[i] in alph) then inc(tmp[s[i]]);
  n2 := 0;
  for ch := 'A' to 'Z' do
  begin
    inc(n2);
    a2[n2] := tmp[ch];
  end;

  for i := 1 to n1 do
    for j := i + 1 to n1 do
      if (a1[i] > a1[j]) then swap(a1[i], a1[j]);

  for i := 1 to n2 do
    for j := i + 1 to n2 do
      if (a2[i] > a2[j]) then swap(a2[i], a2[j]);

    ASSERT(n1 = n2);

    ans := true;
    for i := 1 to n1 do
      if (a1[i] <> a2[i]) then ans := false;

    if (ans) then
      write('YES')
    else
      write('NO');
end;

begin
  assign(input, cin_file);
  reset(input);
  assign(output,  cout_file);
  rewrite(output);

  solve;

  close(input);
  close(output);
end.