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'"; int i = 0; 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 (prev > nprev) { auto d = (prev - nprev) / 2; ans += d; //r += max(0, (i + 1) * (prev - nprev - 2 * d)); r += max(0, (prev - nprev - 2 * d)); prev = nprev; } else { auto d = nprev - prev; r += d; auto e = min(prev, r); ans += e; prev -= e; r -= e; } log([prev, nprev, r, ans]); i++; } r += prev; ans += r / 2; writeln(ans); }