N = int(input()) lsS = list(map(int,list(input()))) cnt = 0 lsS1 = [] pS = set([3,5,7]) for i in range(N): if lsS[i] in pS: cnt += 1 else: lsS1.append(lsS[i]) cn1 = 0 cn9 = 0 for s in lsS1: if s == 1: if cn9 >= 2: cnt += 1 cn9 -= 1 else: cn1 += 1 else: if cn1 > 0: cnt += 1 cn1 -= 1 else: cn9 += 1 cnt += cn1//2 print(cnt)