using System; using System.Collections.Generic; using System.Linq; class Program { static int ReadInt() { return int.Parse(Console.ReadLine()); } static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); } static string[] ReadStrings() { return Console.ReadLine().Split(); } static int Calc(string s, List xs) { var ss = new List[26]; for (int i = 0; i < ss.Length; i++) ss[i] = new List(); for (int i = 0; i < s.Length; i++) { ss[s[i] - 'A'].Add(i); } int ans = 0; for (int i = 0; i < xs.Count; i++) { var t = xs[i]; foreach (var p in ss[t[0] - 'A']) { bool ok = true; for (int j = 0; j < t.Length; j++) { if (p + j < s.Length && s[p + j] == t[j]) { // ok } else { ok = false; break; } } if (ok) ans++; } } return ans; } static void Main() { var s = Console.ReadLine(); int m = ReadInt(); var xs = new List(); for (int i = 0; i < m; i++) xs.Add(Console.ReadLine()); var ans = Calc(s, xs); Console.WriteLine(ans); } }