A, B = input(), input() def predicate() -> bool: if set(A) != set(B): return False for a in set(A): if A.count(a) != B.count(a): return False return True print('YES' if predicate() else 'NO')