#include using namespace std; #define int long long mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); struct MillerRabin { int modpow(int a, int n, int mod) { if (n == 0) return 1; if (n % 2 == 0) { int t = modpow(a, n / 2, mod); return t * t % mod; } return a * modpow(a, n - 1, mod) % mod; } int modinv(int n, int mod) { return modpow(n, mod - 2, mod); } bool is_prime(int n, int k = 50) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; int d = n - 1; while (d % 2 == 0) { d /= 2; } for (int i = 0; i < k; i++) { int a = rnd() % (n - 2) + 1; int t = d; int y = modpow(a, t, n); while (t != n - 1 && y != 1 && y != n - 1) { y = modpow(y, 2, n); t *= 2; } if (y != n - 1 && t % 2 == 0) { return false; } } return true; } } mr; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; string t; int ans = 0; int one = 0, nine = 0; for (char c : s) { if (!(c == '1' || c == '9')) { ans++; } else { t += c; } } int kyu = 0; int ichi = 0; // 19 for (int i = (int)t.size() - 1; i >= 0; i--) { if (t[i] == '9') { kyu++; } else { if (kyu) { ans++; kyu--; } else { ichi++; } } } // 991 ans += min(kyu / 2, ichi); cout << ans << endl; }