n = int(input()) s = input() for i in "357": s = s.replace(i,"") ans = n - len(s) #11,19,991 one = nine = 0 for i,si in enumerate(s): if si == "1": one += 1 else: if one: ans += 1 one -= 1 else: nine += 1 c = min(one,nine//2) ans += c one -= c nine -= 2*c ans += one//2 print(ans)