#include #define rep(i, a) rep2 (i, 0, a) #define rep2(i, a, b) for (int i = (a); i < (b); i++) #define repr(i, a) repr2 (i, 0, a) #define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--) #define asn(a, b, c) fill_n(&(b), sizeof(a) / sizeof(b), c) using namespace std; typedef long long ll; const ll inf = 1e9; const ll mod = 1e9 + 7; int main() { int N; cin >> N; string S; cin >> S; vector num(26); rep (i, S.length()) num[S[i] - 'a']++; vector sum(26); partial_sum(num.begin(), num.end(), sum.begin()); int u = num['z' - 'a']; // z int ans = u; u -= u; // y* u += sum['y' - 'a' - 1] - sum['u' - 'a']; int y = min(num['y' - 'a'], u); num['y' - 'a'] -= y; u -= y; u += max(0, num['u' - 'a'] - num['y' - 'a']); num['u' - 'a'] -= max(0, num['u' - 'a'] - num['y' - 'a']); // yu* u += sum['u' - 'a' - 1] - sum['k' - 'a']; int yu = min(min(num['y' - 'a'], num['u' - 'a']), u); num['y' - 'a'] -= yu; num['u' - 'a'] -= yu; u -= yu; u += max(0, num['k' - 'a'] - min(num['y' - 'a'], num['u' - 'a'])); num['k' - 'a'] -= max(0, num['k' - 'a'] - min(num['y' - 'a'], num['u' - 'a'])); // yuk* u += sum['k' - 'a' - 1] - sum['i' - 'a']; int yuk = min({num['y' - 'a'], num['u' - 'a'], num['k' - 'a'], u}); ans += y + yu + yuk; cout << ans << endl; return 0; }