#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N; scanf("%lld", &N); string t; cin >> t; string s; ll res = 0; ll cnt1 = 0, cnt9 = 0; for (ll i = 0; i < N; i++) { if (t[i] != '1' && t[i] != '9') { res++; } else if (t[i] == '1') { cnt1++; } else { if (cnt1 > 0) { cnt1--; res++; } else cnt9++; } } //cout << res << endl; ll mn = min(cnt9 / 2, cnt1); cnt9 -= mn * 2; cnt1 -= mn; res += mn; res += cnt1 / 2; cout << res << endl; return 0; }