n = int(input()) s = list(str(input())) s.reverse() ans = 0 cnt1 = 0 cnt9 = 0 for c in s: if c == '3' or c == '5' or c == '7': ans += 1 elif c == '1': if cnt1: cnt1 -= 1 ans += 1 elif cnt9: cnt9 -= 1 ans += 1 else: cnt1 += 1 else: if cnt1 and cnt9: cnt1 -= 1 cnt9 -= 1 ans += 1 else: cnt9 += 1 print(ans)