using System; namespace yukicoder { class Program { static void Main(string[] args) { string a = Console.ReadLine(); int ans = 8; int count = 0; int num1 = a.IndexOf("1", 0); int num7 = a.IndexOf("7", 0); string str = ""; str = a.Remove(num1,1); str = str.Remove(num7-1, 1); if (str.Length >= ans) { count=str.Length - ans; } else { count = ans-str.Length; } Console.WriteLine(count); } } }