N = int(input()) S = list(input()) T = list(input()) s = [S.count("A"), S.count("B"), S.count("C")] t = [T.count("A"), T.count("B"), T.count("C")] if s[1] == 0: if S == T: print("Yes") else: print("No") else: if s[1] == t[1] and s[0] >= t[0]: ab, ac, bc = 0, 0, 0 for i in range(N): if S[i] == T[i]: continue elif S[i] == "A" and T[i] == "B": ab += 1 elif S[i] == "A" and T[i] == "C": ac += 1 elif S[i] == "B" and T[i] == "C": bc += 1 else: print("No") exit() if bc: if ab == bc: print("Yes") else: print("NO") else: if ab == ac == 0: print("Yes") else: print("No") else: print("No")