using System; namespace No345 { class Program { static void Main(string[] args) { int sum; int result = 100; string word = "cww"; string text = Console.ReadLine(); for (int i = 0; i < text.Length; i++) if (text[i] == word[0]) if ((sum = Search(text.Substring(i), word)) < result) result = sum; Console.WriteLine(result); } static int Search(string text, string word) { int pointer = 1; int[] counter = new int[word.Length]; foreach (char s in text) { if (word[pointer] == s) { pointer++; if (pointer == word.Length) break; } counter[pointer]++; } int sum = 1; if (pointer == word.Length) { for (int i = 1; i < word.Length; i++) sum += counter[i]; } else sum = -1; return sum; } } }