prime = [3,5,7,11,19,991] prime357 = [3,5,7] import bisect n = int(input()) s = list(map(int, list(input()))) count = 0 s_except357 = [] for i in s: if i in prime357: count += 1 else: s_except357.append(i) len19 = len(s_except357) cnt1 = 0 list1 = [] next = [] for i in range(len19): if s_except357[i] == 1: cnt1 += 1 list1.append(i) elif cnt1 > 0: list1.pop() count += 1 cnt1 -= 1 else: next.append(i) next.extend(list1) s_91 = [s_except357[i] for i in next] s_91.sort() center = bisect.bisect_left(s_91, 5) one = center nine = len(s_91) - center if one >= nine//2: count += nine//2 one -= nine//2 count += one // 2 else: count += one print(count)