#!/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) # %% stack = [0] for x in map(int, S): if stack[-1] == 1: answer += 1 stack.pop() elif stack[-2:] == [9, 9] and x == 1: answer += 1 stack.pop() stack.pop() else: stack.append(x) # %% print(answer)