//#pragma GCC optimize ("-O3","unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define REVERSE(v,n) reverse(v,v+n); #define VREVERSE(v) reverse(v.begin(), v.end()); #define ll long long #define pb(a) push_back(a) #define print(x) cout< inline void chmin(T1 & a, T2 b) { if (a > b) a = b; } template inline void chmax(T1& a, T2 b) { if (a < b) a = b; } typedef pairP; const int MOD = 1e9 + 7; const int MAX = 200060; const double pi = acos(-1); const ll INF = 1e18; void solve() { ll ans = 0; string S; int N; cin >> N >> S; int nine = 0, one = 0; REP(i, N) { if (S[i] == '3' || S[i] == '7'||S[i]=='5')ans++; else if (S[i] == '9') { if (one>0) { one--; ans++; } else nine++; } else { if (nine >= 2) { nine -= 2; ans++; } else one++; } } ans += one / 2; print(ans); } signed main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }