N=int(input()) S=input() mp=[0 for i in range(10)] for c in S: mp[ord(c)-ord('0')]+=1 S=S[::-1] res=mp[3]+mp[5]+mp[7] c1=0 c9=0 for c in S: if c=='1': if c9>0: c9-=1 res+=1 else: c1+=1 if c=='9': c9+=1 res+=c1//2 print(res)