#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define ld long double #define EPS 1e-9 #define INF 1e9 #define LINF (ll)INF*INF #define MOD 1000000007 #define rep(i,n) for(int i=0;i<(n);i++) #define loop(i,a,n) for(int i=a;i<(n);i++) #define all(in) in.begin(),in.end() #define shosu(x) fixed< vi; typedef vector vs; typedef pair pii; typedef pair ppi; typedef pair pip; typedef vector vp; typedef vector vvi; int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);} int lcm(int a, int b){return a/gcd(a,b)*b;} signed main(void) { int n; cin >> n; string s; cin >> s; //11,19,991 int ans = 0; set a,b;//1,9 rep(i,n){ switch (s[i]) { case '1': a.insert(i);break; case '9': b.insert(i);break; case '3':; case '5':; case '7':ans++;break; } } //cout << ans << endl; //for(auto x: a)cout << " "<< x;cout << endl; //for(auto x: b)cout << " "<< x;cout << endl; int p = a.size(), q = b.size(); for(auto x: a){ auto itr = b.lower_bound(x); int num1 = *itr; //cout << x << endl; //for(auto y:b)cout << " " << y;cout << endl; if(itr != b.end()){ ans++;//19 p--,q--; b.erase(num1); } } //cout << ans << " " << p << " " << q << endl; //9…9911…1 , q,p int t = min(q/2,p);//991の個数 ans += t; p -= t; ans += p/2; cout << ans << endl; }