#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int n; cin >> n; string s; cin >> s; int ans = 0; string t; rep(i,n){ if(s[i] == '1' || s[i] == '9'){ t += s[i]; }else{ ans++; } } int m = t.size(); int one = 0; int nine = 0; rep(i,m){ if(t[i] == '1'){ one++; }else{ if(one == 0){ nine++; }else{ one--; ans++; } } } nine = nine / 2; ans += min(nine, one); one -= min(nine, one); ans += one / 2; cout << ans << endl; return 0; }