// yukicoder: No.145 yukiover // 2019.8.7 bal4u #include #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } int f[128]; int ans; void rec(char *s, int a) { int c, n; char *p; if (*s == 0) return; n = 0; for (c = a; c < *s; c++) n += f[c]; p = s-1; while (*++p) if (n > f[*p]) n = f[*p]; ans += n, p = s; while (*p) f[*p++] -= n; n = 1000000; p = s; while (*++p) if (n > f[*p]) n = f[*p]; if (n > f[*s]/2) n = f[*s]/2; ans += n, p = s+1; while (*p) f[*p++] -= n; rec(s+1, *s+1); } int main() { int N; N = in(); while (N--) f[gc()]++; rec("ikuy", 'a'); printf("%d\n", ans + f['z']); return 0; }