N = int(input()) S = input() s1 = 'HAPPY' s2 = S[-5:] ans = 0 for i in range(5): if s1[i] != s2[i]: ans +=1 ans += S[:N-5].count('HAPPY') print(ans)