#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; 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 l1 = 0, l9 = 0, r1 = v.size(), r9 = v.size(); while (l1 < r1 || l9 < r9) { while (l1 < r1 && v[l1] != 1) ++l1; while (l9 < r9 && v[l9] != 9) ++l9; while (l1 < r1 && v[r1 - 1] != 1) --r1; while (l9 < r9 && v[r9 - 1] != 9) --r9; if (l1 >= r1) break; if (l9 >= r9) { int one = 0; while (l1 < r1) one += v[l1++] == 1; ans += one / 2; break; } if (l1 < l9) { // 11...19* ++ans; ++l1; ++l9; } else if (r1 < r9) { // *19...99 ++ans; --r1; --r9; } else { // 911...9*1 ++l9; while (l9 < r9 && v[l9] != 9) ++l9; if (l9 < r9) { ++ans; ++l9; --r1; } } } cout << ans << endl; }