n=int(input()) s=input() ans=0 c="" for i in s: if i == "3" or "5" or "7": ans+=1 else: c+=i end9=-1 cnt=0 for i in range(len(c))[::-1]: if c[i]=="9" and end9==-1:end9=i;cnt+=1 if c[i]=="9":cnt+=1 if end9 == -1: print(ans+len(c)//2) else: ans+=min(end9+1-cnt,cnt) print(ans+(len(c)-end9-1)//2)