#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; typedef pair, int> PP; int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 }; const ll INF = 1e15; const int MAX = 510000; const ll MOD = 1000000007; int main(void) { int N; cin >> N; string S; cin >> S; int ichi = 0, kyu = 0, ans = 0; for (int i = 0; i < N; i++) { if (S[i] == '1') ichi++; else if (S[i] == '9') { kyu++; if (ichi > 0) { ans++; ichi--; kyu--; } } else ans++; } ans += min(ichi, kyu / 2); ichi -= min(ichi, kyu / 2); ans += ichi / 2; cout << ans << endl; }