#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair P; #define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++) #define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++) #define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--) #define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--) const ll INF = 1145141919; const ll MOD = 1000000007; template void chmax(T &a, const T &b){if(a < b){a = b;}} template void chmin(T &a, const T &b){if(a > b){a = b;}} char s[202020]; ll flg[202020]; int main(){ ll N, ans = 0; cin >> N; rep1(i, N){ cin >> s[i]; if(s[i] == '3')ans++; if(s[i] == '5')ans++; if(s[i] == '7')ans++; } ll one = 0; ll nine = 0; rrep1(i, N){ if(s[i] == '9')nine++; if(s[i] == '1'){ if(nine){ nine--; ans++; } else one++; } } ans += one / 2; cout << ans << endl; return 0; }