#include #include #include using namespace std; string s; int n, ans, rem1; vector pos1, pos9; int main() { scanf("%d", &n); for (int i = 0, x; i < n; ++i) { scanf(" %1d", &x); if (x == 3 || x == 5 || x == 7) { ++ans; } else s += '0' + x; } n = s.size(); s = ' ' + s; for (int i = 1; i <= n; ++i) { if (s[i] == '1') pos1.push_back(i); else pos9.push_back(i); } auto it = pos9.begin(); for (auto i : pos1) { auto pos = lower_bound(it, pos9.end(), i); if (pos < pos9.end()) { ++ans; it = next(pos); } else ++rem1; } printf("%d\n", ans + rem1 / 2); return 0; }