#include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template using vi = vector; template using vii = vector>; template using viii = vector>; struct unionfind { vector d; vector cnt; unionfind(int n = 0) : cnt(n) { d = vector(n, -1); } int find(int x) { if (d[x] < 0) return x; return d[x] = find(d[x]); } bool unite(int x, int y) { int rx = find(x); int ry = find(y); if (rx == ry) { cnt[rx]++; return false; } if (d[rx] > d[ry]) swap(rx, ry); d[rx] += d[ry]; d[ry] = rx; cnt[rx] = max(cnt[rx], cnt[ry]) + 1; return true; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return -d[find(x)]; } }; int main() { int n; string s; cin >> n >> s; vi> d(3); rep(i, 3 * n) d[i % 3][s[i]]++; string con = "con"; int ans = 0; vi p = { 0, 1, 2 }; do { int pos = 0; int ta = 0; rep(i, 3) { while (pos % 3 != p[i]) pos++; if (pos >= 3 * n) break; int temp = n; rep(j, 3) { int idx = (p[i] + j) % 3; temp = min(temp, d[idx][con[j]]); } ta += min((3 * n - pos) / 3, temp); pos += min((3 * n - pos) / 3, temp) * 3; } ans = max(ans, ta); } while (next_permutation(p.begin(), p.end())); cout << ans << endl; return 0; }