#include #define rep(i,n) for(int i=0;i pp; const int INF = 1e9; const int MOD = 1000000007; int main() { int n; cin >> n; string s; cin >> s; int cnt = 0; rep(i,n){ if(s[i]-'0' != 1 && s[i]-'0' != 9) cnt ++; } int i = 0,j = 0; while(i < n && j < n){ while(s[i]-'0' != 1 && i < n) i++; if(j < i) j = i; if(j >= n) break; while(s[j]-'0' != 9 && j < n) j ++; if(i < n && j < n){ cnt ++; s[i] = '3';s[j] = '3'; } } int k = 0; i = 0,j = 0; while(i < n && j < n && k < n){ while(s[i] - '0' != 9 && i < n) i++; j = i + 1; if(j >= n) break; while(s[j] -'0' != 9 && j < n) j ++; if(k < j) k = j; if(k >= n) break; while(s[k] -'0' != 1 && k < n) k ++; if(i < n && j < n && k < n){ cnt ++; s[i] = '3';s[j]='3';s[k] = '3'; } } i = 0; int one = 0; while(i < n){ if(s[i]-'0' == 1) one ++; i ++; } cnt += one/2; cout << cnt << endl; return 0; }