program ta;

{$APPTYPE CONSOLE}
{$R+,Q+,S+,H+}

uses
  Math,
  SysUtils;

Type
  Integer=LongInt;
  Real=Extended;

Const
  TaskID='ancient';
  InFile=TaskID+'.in';
  OutFile=TaskID+'.out';
  MaxLen=102;

Var
  A,B:String;
  Res:Boolean;

Procedure Load;
Begin
  ReSet(Input,InFile);
  ReadLn(A);
  ReadLn(B);
  A:=Trim(A);
  B:=Trim(B);
  Close(Input);
End;

Procedure Solve;
Var
  AmA,AmB:Array[Char]Of Integer;
  SA,SB:Array[0..MaxLen]Of Integer;
  I:Integer;
  Ch:Char;
Begin
  Res:=False;
  If Length(A)<>Length(B) Then Exit;
  FillChar(AmA,SizeOf(AmA),0);
  FillChar(AmB,SizeOf(AmB),0);
  FillChar(SA,SizeOf(SA),0);
  FillChar(SB,SizeOf(SB),0);
  For I:=1 To Length(A) Do Inc(AmA[A[I]]);
  For I:=1 To Length(B) Do Inc(AmB[B[I]]);
  For Ch:=Low(Char) To High(Char) Do Inc(SA[AmA[Ch]]);
  For Ch:=Low(Char) To High(Char) Do Inc(SB[AmB[Ch]]);
  For I:=0 To MaxLen Do If SA[I]<>SB[I] Then Exit;
  Res:=True;
End;

Procedure Save;
Begin
  ReWrite(Output,OutFile);
  If Res Then WriteLn('YES') Else WriteLn('NO');
  Close(Output);
End;

begin
  Load;
  Solve;
  Save;
end.
 