#include using namespace std; #define FOR(i, n, m) for (int i = n; i < (int)m; ++i) #define REP(i, n) FOR(i, 0, n) #define REP_1(i, n) for (int i = 1; i <= (int)n; ++i) #define RFOR(i, n, m) for (int i = (int)n - 1; i >= (int)m; --i) #define RREP(i, n) RFOR(i, n, 0) #define RREP_1(i, n) for (int i = (int)n; i >= 1; --i) #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define SIZE(v) (int)v.size() #define EMPTY(v) v.empty() #define SORT(v) sort(ALL(v)) #define RSORT(v) sort(RALL(v)) #define REVERSE(v) reverse(ALL(v)) #define UNIQUE(v) (SORT(v), v.erase(unique(ALL(v)), v.end())) #define PB push_back #define EB emplace_back #define MP make_pair #define YES() cout << "YES\n" #define NO() cout << "NO\n" #define Yes() cout << "Yes\n" #define No() cout << "No\n" #define YESNO(cond) cout << ((cond) ? "YES" : "NO") << '\n' #define YesNo(cond) cout << ((cond) ? "Yes" : "No") << '\n' #define IN(x, a, b) ((a) <= (x) && (x) < (b)) #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) #define FASTIO() \ ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr) #define PRECISION(n) cout << fixed << setprecision(n) using P = pair; using ll = long long; using ull = unsigned long long; using ld = long double; template using min_queue = priority_queue, greater>; template using max_queue = priority_queue; constexpr ll INF = 1000000000; constexpr ll INFL = (ll)1000000000000001000LL; constexpr ll MOD = 998244353; constexpr ld PI = 3.141592653589793238462643383279; constexpr ld EPS = 1e-9; constexpr int dx4[] = {-1, 1, 0, 0}; constexpr int dy4[] = {0, 0, -1, 1}; constexpr int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}; constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}; void solve() { int n; string s; cin >> n >> s; int ans = 0; if (s[n - 5] != 'H') ans++; if (s[n - 4] != 'A') ans++; if (s[n - 3] != 'P') ans++; if (s[n - 2] != 'P') ans++; if (s[n - 1] != 'Y') ans++; for (int i = n - 6; i >= 0; i--) { if (s.substr(i, 5) != "HAPPY") continue; ans++; } cout << ans << endl; } int main() { FASTIO(); int t = 1; while (t--) { solve(); } }