using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("ilovechiwawa"); //6 } else if (InputPattern == "Input2") { WillReturn.Add("wachiwachi"); //-1 } else if (InputPattern == "Input3") { WillReturn.Add("chiwaaaaaaamikawayadeeeeesu"); //16 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); IEnumerable MatchEnum = Regex.Matches(InputList[0], "c[^c]*?w.*?w").Cast(); Console.WriteLine(MatchEnum.Any() ? MatchEnum.Max(X => X.Value.Length) : -1); } }