using System; using System.Linq; namespace lv1_804 { class Program { static void Main(string[] args) { string s = Console.ReadLine(); if (s.Length == 1) { Console.WriteLine(-1); return; } if (s[0] == '1') { if (s.Skip(1).All(x => x == '3')) Console.WriteLine(s.Length - 1); else Console.WriteLine(-1); } else Console.WriteLine(-1); } } }