import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] value = sc.next().toCharArray(); int length = value.length; long[][] hashes = new long[10][length]; ArrayList> counts = new ArrayList<>(); for (int i = 0; i < 10; i++) { counts.add(new HashMap<>()); } for (int i = 0; i < length; i++) { hashes[0][i] = value[i] - 'A'; counts.get(0).put(hashes[0][i], counts.get(0).getOrDefault(hashes[0][i], 0) + 1); } for (int i = 1; i < 10; i++) { for (int j = 0; j < length - i; j++) { hashes[i][j] = hashes[i - 1][j] * 26 + hashes[0][j + i]; counts.get(i).put(hashes[i][j], counts.get(i).getOrDefault(hashes[i][j], 0) + 1); } } int m = sc.nextInt(); int ans = 0; for (int i = 0; i < m; i++) { String s = sc.next(); ans += counts.get(s.length() - 1).getOrDefault(getHash(s), 0); } System.out.println(ans); } static long getHash(String s) { long hash = 0; for (char c : s.toCharArray()) { hash *= 26; hash += c - 'A'; } return hash; } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }