#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% N = int(readline()) S = read().rstrip().decode() # %% S = S.replace('3', '') S = S.replace('5', '') S = S.replace('7', '') answer = N - len(S) # %% T = [0] for x in map(int, S): if x == 9 and T[-1] == 1: answer += 1 T.pop() else: T.append(x) x9 = T.count(9) x1 = T.count(1) n = min(x9 // 2, x1) answer += n x1 -= n answer += x1 // 2 print(answer)