#include using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int ret = 0; stack stk; for (int i = 0; i < n; i++) { char c; cin >> c; if (c == '1') { stk.push(1); } else if (c == '9') { if (!stk.empty() && stk.top() == 1) { stk.pop(); ++ret; } else { stk.push(9); } } else { ++ret; } } int one = 0; while (!stk.empty()) { if (stk.top() == 1) ++one; stk.pop(); } ret += one / 2; cout << ret << endl; return 0; }