from collections import Counter N = int(input()) S = input() one = 0 nine = 0 ans = 0 # 11, 19, 991 for s in S: if s == '3' or s == '5' or s == '7': ans += 1 else: if s == '9': if one > 0: ans += 1 one -= 1 else: nine += 1 elif s == '1': if nine >= 2: ans += 1 nine -= 2 else: one += 1 print(ans)