import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.string; void main() { auto N = readln.chomp.to!int; auto S = readln.chomp; auto T = S.filter!(s => s == '1' || s == '9').array; int ans = S.length.to!int - T.length.to!int; int ichi = 0; int kyuu = 0; foreach_reverse (i; 0..T.length.to!int) { if (T[i] == '1') { if (kyuu > 0) { ans += 1; kyuu -= 1; } else { ichi += 1; } } else { kyuu += 1; } } ans += ichi / 2; ans.writeln; }