#!/usr/bin/env python3 n = int(input()) s = input() s = ''.join(s.split('3')) s = ''.join(s.split('5')) s = ''.join(s.split('7')) ans = n - len(s) n = len(s) # dp[checked 0 ~ i][# one][# nine] dp = [[[-10**5] * 3 for _ in range(3)] for _ in range(n + 1)] dp[0][0][0] = 0 for i in range(n): if s[i] == '1': dp[i + 1][1][0] = max(dp[i + 1][1][0], dp[i][0][0]) # '' -> '1' dp[i + 1][1][1] = max(dp[i + 1][1][1], dp[i][0][1]) # '' -> '1' dp[i + 1][1][2] = max(dp[i + 1][1][2], dp[i][0][2]) # '' -> '1' dp[i + 1][0][0] = max(dp[i + 1][0][0], dp[i][1][0] + 1) # '1' -> '11' -> '' dp[i + 1][0][1] = max(dp[i + 1][0][1], dp[i][1][1] + 1) # '1' -> '11' -> '' dp[i + 1][0][2] = max(dp[i + 1][0][2], dp[i][1][2] + 1) # '1' -> '11' -> '' dp[i + 1][0][0] = max(dp[i + 1][0][0], dp[i][0][2] + 1) # '99' -> '991' -> '' dp[i + 1][1][0] = max(dp[i + 1][1][0], dp[i][1][2] + 1) # '99' -> '991' -> '' else: dp[i + 1][0][1] = max(dp[i + 1][0][1], dp[i][0][0]) # '' -> '9' dp[i + 1][1][1] = max(dp[i + 1][1][1], dp[i][1][0]) # '' -> '9' dp[i + 1][0][2] = max(dp[i + 1][0][2], dp[i][0][1]) # '9' -> '99' dp[i + 1][1][2] = max(dp[i + 1][1][2], dp[i][1][1]) # '9' -> '99' dp[i + 1][0][0] = max(dp[i + 1][0][0], dp[i][1][0] + 1) # '1' -> '19' -> '' dp[i + 1][0][1] = max(dp[i + 1][0][1], dp[i][1][1] + 1) # '1' -> '19' -> '' dp[i + 1][0][2] = max(dp[i + 1][0][2], dp[i][1][2] + 1) # '1' -> '19' -> '' add = 0 for i in range(3): for j in range(3): add = max(add, dp[n][i][j]) ans += add print(ans)