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, HashSet hs) { int len = hs.Select(e => s.Length).Max(); int ans = 0; for (int i = 0; i < s.Length; i++) { for (int j = 1; j <= len; j++) { if (i + j > s.Length) break; var t = s.Substring(i, j); if (hs.Contains(t)) { ans++; } } } return ans; } static void Main() { var s = Console.ReadLine(); int m = ReadInt(); var hs = new HashSet(); for (int i = 0; i < m; i++) hs.Add(Console.ReadLine()); var ans = Calc(s, hs); Console.WriteLine(ans); } }