#include using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string S; cin >> S; // 11, 19, 991 を何個とることができるかを考える。 int count1 = 0; int count1deleted = 0; int ans = 0; for (char &s : S){ if (s == '1'){ ++count1; }else if (s == '9'){ if (count1 > 0){ --count1; ++count1deleted; ++ans; s = '0'; } }else if (s == '3' or s == '5' or s == '7'){ ++ans; } } for (char &s : S){ if (s == '1' and count1deleted > 0){ --count1deleted; s = '0'; if (count1deleted == 0) break; } } int count9 = 0; for (char &s : S){ if (s == '1'){ if (count9 >= 2){ count9 -= 2; ++ans; --count1; } }else if (s == '9'){ ++count9; } } cout << ans + count1 / 2 << endl; return 0; }