#!/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) rl = [] p = 0 for i in range(n - 1): if s[i] != s[i + 1]: rl.append(s[p:i + 1]) p = i + 1 rl.append(s[p:]) if rl[0][0] == '9': rl = [''] + rl if len(rl) % 2 != 0: rl = rl + [''] m = len(rl) cnt = [len(x) for x in rl] # delete 19 for i in range(m - 2)[::2]: j = i + 1 while j < m and cnt[i] > 0: c = min(cnt[i], cnt[j]) ans += c cnt[i] -= c cnt[j] -= c j += 2 cnt[i + 2] += cnt[i] # delete 991 for i in range(m - 3)[1::2]: j = i + 1 while j < m and cnt[i] > 1: c = min(cnt[i] // 2, cnt[j]) ans += c cnt[i] -= 2 * c cnt[j] -= c j += 2 cnt[i + 2] += cnt[i] # delete 11 s = 0 for i in range(m)[::2]: s += cnt[i] ans += s // 2 print(ans)