#include using namespace std; int main() { int64_t N; string S; cin >> N >> S; vector c_num(3, 0), o_num(3, 0), n_num(3, 0); for (int64_t i = 0; i < 3 * N; i++) { if (S[i] == 'c') { c_num[i % 3]++; } else if (S[i] == 'o') { o_num[i % 3]++; } else if (S[i] == 'n') { n_num[i % 3]++; } } int64_t ans = 0; multiset st; for (int64_t i = 0; i < 3; i++) { const int64_t add = min({ c_num[i], o_num[(i + 1) % 3], n_num[(i + 2) % 3] }); if (add == 0) { continue; } ans += add; st.insert(add); } if (ans == N && st.size() == 3 && *st.begin() == 1) { // 先頭をバラせば後者二つが手に入る ans--; } else { const int64_t waste = N - ans; const int64_t sub = max((int64_t)(st.size() - 1) - waste, (int64_t)0); ans -= sub; } cout << ans << endl; }