#include using namespace std; using ll = long long; const int mod = 1e9 + 7; const int inf = (1 << 30) - 1; const ll infll = (1LL << 61) - 1; #define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) int N, ans, one, nine, other; string s, t = ""; int main() { cin >> N >> s; for (int i = 0; i < N; i++) { if (s[i] == '1') one++, t = t + "1"; else if (s[i] == '9') nine++, t = t + "9"; else ans++; } N = t.size(); int now_one = 0, now_nine = 0; for (int i = 0; i < N; i++) { if (t[i] == '1') { now_one++; } else { now_nine++; if (now_one > 0) now_one--, now_nine--, ans++; } } ans += now_one / 2; cout << ans << endl; }