using System; using System.Collections.Generic; using System.Linq; class Program { static void Main(string[] args) { string S = "waaichiwawaakarichiwawadaisuki";// Console.ReadLine(); int wCnt = 0; string chk = ""; List cwwCntList = new List(); for (int i = 0; i < S.Length; i++) { if (S[i] != 'c') continue; wCnt = 0; chk = S.Substring(i + 1); for (int j = 0; j < chk.Length; j++) { if (chk[j] != 'w') continue; wCnt++; if (2 <= wCnt) { cwwCntList.Add(j + 2); break; } } } Console.WriteLine(cwwCntList.Count == 0 ? -1 : cwwCntList.Min()); } }