""" 3 5 7 11 19 991 """ n = int(input()) S = input() lst = [] ans = 0 for s in S: if s in "357": ans += 1 elif s == "1": if len(lst) >= 2 and lst[-1] == 9 and lst[-2] == 9: ans += 1 lst.pop() lst.pop() else: lst.append(1) else: if lst and lst[-1] == 1: ans += 1 lst.pop() else: lst.append(9) c = lst.count(1) print(ans + c // 2)