using System; class Program { static void Main(string[] args) { var input = Console.ReadLine(); int len = input.Length; for (int i = 0; i < input.Length; i++) if (input[i] == 'c') for (int j = i + 1; j < input.Length; j++) if (input[j] == 'w') for (int k = j + 1; k < input.Length; k++) if (input[k] == 'w') len = Math.Min(len, k - i + 1); Console.WriteLine(len == input.Length ? -1 : len); } }