""" 3 5 7 11 19 991 """ n = int(input()) S = input() T = [] ans = 0 for s in S: if s in "357": ans += 1 else: T.append(int(s)) S = T T = [] for s in S: if s == 1: T.append(1) else: if T and T[-1] == 1: ans += 1 T.pop() else: T.append(9) nine = T.count(9) one = T.count(1) mi = min(nine // 2, one) ans += mi one -= mi ans += one // 2 print(ans)