using System; using System.Collections.Generic; class Program { static void Main() { string s = Console.ReadLine(); List cPosis = new List(); List wPosis = new List(); int l = s.Length; for (int i = 0; i < l; i++) { if (s[i] == 'c') { cPosis.Add(i); } else if (s[i] == 'w') { wPosis.Add(i); } } int cC = cPosis.Count; int wC = wPosis.Count; int ans = 101; int w = 0; for (int c = 0; c < cC; c++) { for (; w < wC - 1 && wPosis[w] < cPosis[c]; w++) ; if (wC - 2 < w) break; int tmp = wPosis[w + 1] - cPosis[c] + 1; if (tmp < ans) ans = tmp; } if (ans == 101) ans = -1; Console.WriteLine(ans); } }