#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); // 3, 5, 7 // 19, 11, 991 int N; string S; cin >> N >> S; int ans = 0, c1 = 0; string T = ""; rep(i,N) { if(set{3, 5, 7}.count(S[i] - '0')) ans++; if(S[i] == '1') c1++; if(S[i] == '9') { if(c1 == 0) T += S[i]; else c1--, ans++; } } int c9 = 0; for(char c : T) if(c == '9') c9++; { int ANS = 0; for(int a1 = 0; a1 <= c1 / 2; a1++) { int r1 = c1 - a1 * 2; int a9 = min(c9 / 2, r1); ANS = max(ANS, a1 + a9); } ans += ANS; } cout << ans << endl; }