using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace yukicoderTest { class Program { static void Main(string[] args) { string str = Console.ReadLine(); int cnt = 0; int max = -1; bool flg = true; for (int i = 0; i < str.Length - 1; i++) { if (str.Substring(i, 1) == 1.ToString()) { for (int j = i + 1; j < str.Length; j++) { if (str.Substring(j, 1) == 3.ToString()) { cnt++; } else { flg = false; break; } if(cnt>max) { max = cnt; } } } } if (flg != false) { Console.WriteLine(max); } else { Console.WriteLine("-1"); } } } }