using System; using System.Linq; class Program { public void Solve() { string N = Console.ReadLine(); if (0 <= N.Substring(1).Where(x => x != '3').Count()) { Console.WriteLine(-1); } else { Console.WriteLine(N.Substring(1).Length); } } static void Main() { var solver = new Program(); solver.Solve(); } }