import std.algorithm; import std.array; import std.ascii; import std.container; import std.conv; import std.math; import std.numeric; import std.range; import std.stdio; import std.string; import std.typecons; void log(A...)(A arg) { stderr.writeln(arg); } int size(T)(in T s) { return cast(int)s.length; } void main() { auto N = readln.chomp.to!int; auto s = readln; int r = 0; int ans = cast(int)s.count!"a == 'z'"; int prev = cast(int)s.count!"a == 'y'"; foreach (p ; zip("yuk", "uki")) { int nprev = 0; foreach (c ; s) { if (p[1] < c && c < p[0]) { if (prev > 0) { prev--; ans++; } } else if (p[1] == c) { nprev++; } } assert(prev >= 0 && nprev >= 0 && r >= 0); if (p[0] == 'y') { auto d = max(0, prev - nprev) / 2; ans += d; r += max(0, prev - nprev - 2 * d); } else { r += abs(prev - nprev); auto d = min(prev, r); ans += d; prev -= d; r -= d; } prev = min(prev, nprev); //log([prev, nprev, r, ans]); } writeln(ans); }