A = input() B = input() c = [] d = [] for i in range(len(A)): if A[i] != B[i]: c += A[i] d += B[i] print(['NO', 'YES'][sorted(A) == sorted(B)])