using System; using System.Text; using System.Linq; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; string text = Reader.ReadLine(); int mtCount = int.Parse(Reader.ReadLine()); Dictionary>> dic = new Dictionary>>(); for(int i=0; i>()); } if(!dic[wrd[0]].ContainsKey(wrd.Length)) { dic[wrd[0]].Add(wrd.Length, new List()); } dic[wrd[0]][wrd.Length].Add(wrd); } long ans = 0; for(int i=0; ia)) { if(key > text.Length - i) { break; } foreach(string wrd in dic[text[i]][key]) { if(wrd.Equals(text.Substring(i, key))) { ans++; break; } } } } Console.WriteLine(ans); } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" ABAACABCAACBABABACBBAC 7 A C AA ABB ABA BA CBBAC "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }