using System; using static System.Console; using System.Linq; using System.Collections.Generic; using System.Security.Cryptography; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var s = ReadLine(); var list = new List(); var one = 0; var ans = 0; foreach (var c in s) { if (c == '3' || c == '5' || c == '7') ++ans; else list.Add(c); if (list.Count > 1 && list[^2] == '1' && list[^1] == '9') { ++ans; list.RemoveAt(list.Count - 1); list.RemoveAt(list.Count - 1); } } var nlist = new List(); foreach (var c in list) { nlist.Add(c); if (nlist.Count > 2 && nlist[^3] == '9' && nlist[^2] == '9' && nlist[^1] == '1') { ++ans; nlist.RemoveAt(nlist.Count - 1); nlist.RemoveAt(nlist.Count - 1); nlist.RemoveAt(nlist.Count - 1); } } foreach (var c in nlist) if (c == '1') ++one; WriteLine(ans + one / 2); } }