program _a;

{$APPTYPE CONSOLE}

Var I,J,K,L,N,M:Longint;
    S:String;
    A,B:Array[Char] Of Longint;
    c1,c2:Char;
    BB:Boolean;

begin
  Assign(input,'ancient.in');
  Reset(input);
  Assign(output,'ancient.out');
  ReWrite(output);
   ReadLn(S);
   FillChar(A,SizeOf(A),0);
   For I:=1 To Length(s) Do
    Inc(A[S[I]]);
   ReadLn(S);
   FillChar(B,SizeOf(B),0);
   For I:=1 To Length(s) Do
    Inc(B[S[I]]);
   For c1:='A' To 'Y' Do
    For c2:=Succ(c1) To 'Z' Do
     If A[c1]>A[c2] Then
      Begin
        K:=A[c1];
        A[c1]:=A[c2];
        A[c2]:=K;
      End;
   For c1:='A' To 'Y' Do
    For c2:=Succ(c1) To 'Z' Do
     If B[c1]>B[c2] Then
      Begin
        K:=B[c1];
        B[c1]:=B[c2];
        B[c2]:=K;
      End;
   BB:=True;
   For c1:='A' To 'Z' Do
    If A[c1]<>B[c1] Then
     BB:=False;
   If BB Then
    Write('YES')
   Else
    Write('NO');
  Close(input);
  Close(output);
end.
