using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; public class Program { public static void Main(string[] args) { new Magatro().Solve(); } } class Magatro { public void Solve() { var s = Console.ReadLine(); int ans = s.Length * 2 + 1; int ans2 = s.Length; int ana = 0; foreach (char c in s) { switch (c) { case '0': case '4': case '6': case '9': ana++; break; case '8': ana += 2; break; } } Console.WriteLine(Math.Min(ans+ana,ans2+(ana+1)*2)); } }