#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; #define PI 3.141592653589793 int main(){ int N; cin >> N; string S; cin >> S; int ans = 0, one = 0, nine = 0; rep(i, N){ if(S[i]!='1' && S[i]!='9') ans++; if(S[i]=='1') one++; if(S[i]=='9'){ if(one>0){ one--; ans++; } } } if(one>0) ans+=one/2; cout <