#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long int ll const MOD = 1000000007; ll const INF = (long long int)1 << 61; ll mypow(ll x,ll n,ll mod = MOD){ ll ret = 1; while(n > 0){ if(n&1){ ret = (ret*x)%mod; } x = (x*x)%mod; n >>= 1; } return ret; } ll mygcd(ll a,ll b){ if(b == 0)return a; return mygcd(b,a%b); } ll twoPow(ll shiftNum){ return (1LL << (shiftNum - 1)); } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; string str; cin >> str; set st1,st2,st3; ll ans = 0; for(int i = 0; i < n; i++){ if(str[i] == '3' || str[i] == '7' || str[i] == '5'){ ans++; }else if(str[i] == '1'){ st1.insert(i); }else{ st3.insert(i); } } /*while(true){ auto itr = st2.begin(); if(itr == st2.end())break; auto r = st3.upper_bound(*itr); if(r != st3.end()){ ans++; st2.erase(itr); st3.erase(r); }else{ break; } }*/ while(true){ auto itr = st3.begin(); if(itr == st3.end()){ break; } bool check = true; auto m = st3.upper_bound(*itr); if(m != st3.end()){ auto r = st1.upper_bound(*m); if(r != st1.end()){ ans++; st3.erase(itr); st1.erase(r); st3.erase(m); }else{ check = false; } }else{ break; } if(!check){ break; } } while(true){ auto itr = st1.begin(); if(itr == st1.end()){ break; } auto r = st3.upper_bound(*itr); if(r != st3.end()){ ans++; st1.erase(itr); st3.erase(r); }else{ break; } } while(true){ auto itr = st1.begin(); if(itr == st1.end()){ break; } auto r = st1.upper_bound(*itr); if(r != st1.end()){ ans++; st1.erase(itr); st1.erase(r); }else{ break; } } cerr << ans << endl; /*while(true){ auto itr = st1.begin(); if(itr == st1.end()){ break; } bool check = true; auto m = st2.upper_bound(*itr); if(m != st2.end()){ auto r = st1.upper_bound(*m); if(r != st1.end()){ ans++; st1.erase(itr); st1.erase(r); st2.erase(m); }else{ check = false; } }else{ break; } if(!check){ break; } }*/ /*while(true){ auto itr = st3.begin(); if(itr == st3.end()){ break; } bool check = true; auto m = st1.upper_bound(*itr); if(m != st1.end()){ auto r = st1.upper_bound(*m); if(r != st1.end()){ ans++; st3.erase(itr); st1.erase(r); st1.erase(m); }else{ check = false; } }else{ break; } if(!check){ break; } }*/ /*while(true){ auto itr = st3.begin(); if(itr == st3.end()){ break; } bool check = true; auto m = st1.upper_bound(*itr); if(m != st1.end()){ auto r = st3.upper_bound(*m); if(r != st3.end()){ ans++; st3.erase(itr); st3.erase(r); st1.erase(m); }else{ check = false; } }else{ break; } if(!check){ break; } }*/ cerr << st1.size() << endl; cerr << st2.size() << endl; cerr << st3.size() << endl; cout << ans << endl; return 0; }