#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N; cin >> N; string S; cin >> S; // 11, 19, 991 int ans = 0, s = 0; vector v; for (char c : S) { const int n = c - '0'; if (n == 3 || n == 5 || n == 7) ++ans; else v.emplace_back(n); } { int l = 0, r = v.size(); vector done(v.size()); while (l < r) { while (l < N && v[l] != 1) ++l; while (r > 0 && v[r - 1] != 9) --r; if (l >= r) break; ++ans; done[l++] = done[--r] = true; } vector nv; REP(i, v.size()) if (!done[i]) nv.emplace_back(v[i]); v = nv; } int one = 0, nine = 0; REP(i, v.size()) { if (v[i] == 1) { if (nine >= 2) { ++ans; nine = -INF; } else ++one; } else ++nine; } ans += one / 2; cout << ans << endl; }