#include using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pii = pair; using pll = pair; template using pq = priority_queue, greater>; const ll LINF=0x1fffffffffffffff; const ll MINF=0x7fffffffffff; const int INF=0x3fffffff; const int MOD=1000000007; const int MOD2=998244353; const ld EPS=1e-9; const ld PI=3.14159265358979323846; const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; #define all(x) (x).begin(), (x).end() #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define per(i, b) per2(i, 0, b) #define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define ALL(c) (c).begin(), (c).end() #define SZ(x) ((int)(x).size()) #define nep(x) next_permutation(ALL(x)) template using V = vector; template using VV = V>; template using VVV = V>; template using VVVV = V>; template using V_p = V>; template using n_pq = priority_queue; template using r_pq = priority_queue,greater>; template ostream &operator<<(ostream &o,const vector&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<ostream &operator<<(ostream &o,const deque&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<ostream &operator<<(ostream &o,const set&v) {o<<"{";for(auto i:v)o<<" "< 0) { if (n & 1) ret *= x; // n の最下位bitが 1 ならば x^(2^i) をかける x *= x; n >>= 1; // n を1bit 左にずらす } return ret; } //////////////////////////////////////////////////// int main() { ll N; cin >> N; string S; cin >> S; VV dp(N+1,V(6,-1)); dp[0][0] = 0; ll max_case; max_case = 0; rep(i,N) { if (S[i] == 'C') { dp[i+1][1] = max_case; if (dp[i][2] >= 0) { dp[i+1][3] = max(dp[i+1][3],dp[i][2]); } } else if (S[i] == 'P') { if (dp[i][1] >= 0) { dp[i+1][2] = max(dp[i+1][2],dp[i][1]); } } else if (S[i] == 'T') { if (dp[i][3] >= 0) { dp[i+1][4] = max(dp[i+1][4],dp[i][3]); } } else if (S[i] == 'F') { if (dp[i][4]>=0) { dp[i+1][0] = max(dp[i+1][0],dp[i][4]+1); max_case = max(max_case,dp[i+1][0]); } } if (S.substr(i,3) == "CPC") { if (dp[i][4] >= 0 and i+3<=N) { dp[i+3][0] = max(dp[i+3][0],dp[i][4]+1); max_case = max(max_case,dp[i+3][0]); } } } cout << max_case << endl; }