import java.io.PrintStream; import java.util.HashMap; import java.util.Scanner; public class Y430 { Y430() throws Exception { Scanner in = new Scanner(System.in); PrintStream out = new PrintStream(System.out); String s = in.next(); int m = in.nextInt(); String[] w = new String[m]; for (int i = 0; i < m; i++) { w[i] = in.next(); } HashMap[] hashMap = new HashMap[11]; for (int i = 0; i < 11; i++) { hashMap[i] = new HashMap(); } for (int i = 0; i < s.length(); i++) { for (int j = 1; j <= 10 && i + j <= s.length(); j++) { Long x = encode(s.substring(i, i+j)); Integer g = hashMap[j].get(x); if (g == null) g = 0; g += 1; hashMap[j].put(x, g); } } int answer = 0; for (int i = 0; i < m; i++) { Long x = encode(w[i]); Integer g = hashMap[w[i].length()].get(x); if (g != null) answer += g; } out.println(answer); } long encode(String s) { long x = 0; for (int i = 0; i < s.length(); i++) { x = x * 26 + (int)s.charAt(i) - 'A'; } return x; } public static void main(String argv[]) throws Exception { new Y430(); } }