N = int(input()) S = input() cnt = S.count("HAPPY") if S.endswith("HAPPY"): print(cnt - 1) else: end = sum([s == happy for s, happy in zip(S[-5:], "HAPPY")]) print(5 - end + cnt)