#include using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int ans = 0; int cnt1 = 0; int cnt9 = 0; for (int i = 0; i < n; i++) { if (s[i] == '3' || s[i] == '5' || s[i] == '7') { ans++; } else if (s[i] == '1') { if (cnt9 >= 2) ans++; else cnt1++; } else { if (cnt1 > 0) { cnt1--; ans++; } else { cnt9++; } } } cout << ans << "\n"; return 0; }