using System; namespace yukicoder { class Program { static void Main(string[] args) { var str = Console.ReadLine(); string[] strings = new string[str.Length]; int C = 0 , W = 0 , Ccnt = str.Length -3 , cc = 0 , Wcnt = 0 , anscount = 0 , temp = str.Length; for (int i = 0; i < str.Length; i++) { if(str.Substring(i,1) == "c" && C == 0) { C = 1; Ccnt = i; } else if (str.Substring(i, 1) == "c" && C == 1 && cc == 0) { cc = i; } else if (str.Substring(i, 1) == "w" && C == 1) { W++; Wcnt = i; } if(C == 1 && W == 2 && Wcnt - Ccnt + 1 > anscount || C == 1 && W == 2 && Wcnt - Ccnt + 1 < anscount )//&& i == str.Length - 1 { if(anscount == 0) { int sum = Wcnt - Ccnt + 1; anscount = sum; i = cc - 1; C = 0; Ccnt = 0; cc = 0; W = 0; Wcnt = 0; } else { int sum2 = Wcnt - Ccnt + 1; if(temp > sum2) { temp = sum2; } i = cc - 1; C = 0; Ccnt = 0; W = 0; Wcnt = 0; cc = 0; } } } if(anscount == 0) { Console.WriteLine("-1"); } else if (anscount > temp) { Console.WriteLine(temp); } else if (anscount < temp) { Console.WriteLine(anscount); } } } }