n = int(input()) s = input() s = ''.join(s.split('3')) s = ''.join(s.split('5')) s = ''.join(s.split('7')) ans = n - len(s) c1 = 0 c9 = 0 for c in s: if c == '1': c1 += 1 else: if c1 > 0: ans += 1 c1 -= 1 else: c9 += 1 while c1 >= 1 and c9 >= 2: ans += 1 c1 -= 1 c9 -= 2 ans += c1 // 2 print(ans)