N = int(input()) S = input() one = 0 nine = 0 ans = 0 for s in S: if s == "1": one += 1 elif s == "9": if one: one -= 1 ans += 1 else: nine += 1 else: ans += 1 d = min(nine // 2, one) ans += d one -= d ans += one // 2 print(ans)