#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define _overload(a, b, c, d, ...) d #define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X)) #define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X)) #define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__) #define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X)) #define all(X) (X).begin(),(X).end() #define len(X) ((int)(X).size()) #define mod(n, m) (((n)%(m)+(m))%m) #define fi first #define sc second using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair Pii; typedef pair Pll; const int INFINT = 1 << 30; // 1.07x10^ 9 const ll INFLL = 1LL << 60; // 1.15x10^18 const double EPS = 1e-10; const int MOD = 1000000007; const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const int MAX_N = 200000; int N; string S; int main() { cin >> N; cin >> S; int ans = 0; string extracted; for (int i = 0; i < N; ++i) { if (S[i] == '1' || S[i] == '9') { extracted += S[i]; } else { ++ans; } } int one = 0; for (int i = 0; i < len(extracted); ++i) { if (extracted[i] == '1') ++one; else { if (one > 0) { ++ans; --one; } } } ans += one/2; cout << ans << endl; return 0; }