#include using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; string S; cin >> S; int counter = 0; int ans = 0; for (char s : S){ if (s == '1'){ ++counter; }else if (s == '9'){ if (counter > 0){ --counter; ++ans; } }else{ ++ans; } } cout << ans + counter / 2 << endl; return 0; }