#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 3e5 + 5;
char s[maxn];
int st[maxn], ed[maxn];
int rk[maxn], tp[maxn], tax[maxn];
int height[maxn], sa[maxn], f[maxn][21], bin[maxn];
int mn[maxn][21], mx[maxn][21];
int M;
void qsort(int n) {
  for (int i = 0; i <= M; i++) tax[i] = 0;
  for (int i = 1; i <= n; i++) tax[rk[i]]++;
  for (int i = 1; i <= M; i++) tax[i] += tax[i - 1];
  for (int i = n; i >= 1; i--) sa[tax[rk[tp[i]]]--] = tp[i];
}
void get_sa(int n) {
  for (int i = 1; i <= n; i++) {
    M = max(M, rk[i] = s[i]);
    tp[i] = i;
  }
  qsort(n);
  for (int w = 1, p = 0; p < n; M = p, w <<= 1) {
    p = 0;
    for (int i = 1; i <= w; i++) tp[++p] = n - w + i;
    for (int i = 1; i <= n; i++) {
      if (sa[i] > w) tp[++p] = sa[i] - w;
    }
    qsort(n);
    for (int i = 0; i <= n; i++) tp[i] = rk[i];
    rk[sa[1]] = p = 1;
    for (int i = 2; i <= n; i++) {
      rk[sa[i]] =
          (tp[sa[i - 1]] == tp[sa[i]] && tp[sa[i - 1] + w] == tp[sa[i] + w])
              ? p
              : ++p;
    }
  }
}
void get_height(int n) {
  int k = 0;
  for (int i = 1; i <= n; i++) {
    if (k) k--;
    int j = sa[rk[i] - 1];
    while (j && s[i + k] == s[j + k]) k++;
    height[rk[i]] = k;
  }
}
void build(int n) {
  for (int i = 1; i <= n; i++) {
    f[i][0] = height[i];
    mn[i][0] = sa[i];
    mx[i][0] = sa[i] <= ed[0] ? sa[i] : 0;
  }
  for (int j = 1; j <= bin[n]; j++) {
    for (int i = 1; i + (1 << j) - 1 <= n; i++) {
      int t = i + (1 << (j - 1));
      f[i][j] = min(f[i][j - 1], f[t][j - 1]);
      mn[i][j] = min(mn[i][j - 1], mn[t][j - 1]);
      mx[i][j] = max(mx[i][j - 1], mx[t][j - 1]);
    }
  }
}
int query1(int x, int y) {
  if (x == y) return 0;
  x++;
  int j = bin[y - x + 1];
  int k = y - (1 << j) + 1;
  return min(f[x][j], f[k][j]);
}
int query2(int x, int y) {
  int j = bin[y - x + 1];
  int k = y - (1 << j) + 1;
  return min(mn[x][j], mn[k][j]);
}
int query3(int x, int y) {
  int j = bin[y - x + 1];
  int k = y - (1 << j) + 1;
  return max(mx[x][j], mx[k][j]);
}
int main() {
  scanf("%s", s + 1);
  ed[0] = strlen(s + 1);
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    s[ed[i - 1] + 1] = '*';
    st[i] = ed[i - 1] + 2;
    scanf("%s", s + st[i]);
    ed[i] = strlen(s + 1);
  }
  int n = strlen(s + 1);
  bin[0] = -1;
  for (int i = 1; i <= n; i++) bin[i] = bin[i >> 1] + 1;
  get_sa(n);
  get_height(n);
  build(n);
  int ans = 0;
  for (int t = 1; t <= m; t++) {
    int flag = 0;
    for (int i = st[t] + 1; i <= ed[t]; i++) {
      int tmp = rk[st[t]], len = ed[t] - st[t] + 1;
      int L = tmp, R = tmp;
      int l = 1, r = tmp - 1, mid, res = 0;
      while (l <= r) {
        mid = (l + r) >> 1;
        if (query1(mid, tmp) >= i - st[t])
          res = mid, r = mid - 1;
        else
          l = mid + 1;
      }
      if (query1(res, tmp) >= i - st[t]) L = res;
      l = tmp + 1, r = n, res = n;
      while (l <= r) {
        mid = (l + r) >> 1;
        if (query1(tmp, mid) >= i - st[t])
          res = mid, l = mid + 1;
        else
          r = mid - 1;
      }
      if (query1(tmp, res) >= i - st[t]) R = res;
      int mnn = query2(L, R);
      if (mnn > ed[0]) continue;
      tmp = rk[i];
      L = tmp, R = tmp;
      l = 1, r = tmp - 1, mid, res = 0;
      while (l <= r) {
        mid = (l + r) >> 1;
        if (query1(mid, tmp) >= len - i + st[t])
          res = mid, r = mid - 1;
        else
          l = mid + 1;
      }
      if (query1(res, tmp) >= len - i + st[t]) L = res;
      l = tmp + 1, r = n, res = n;
      while (l <= r) {
        mid = (l + r) >> 1;
        if (query1(tmp, mid) >= len - i + st[t])
          res = mid, l = mid + 1;
        else
          r = mid - 1;
      }
      if (query1(tmp, res) >= len - i + st[t]) R = res;
      int mxx = query3(L, R);
      if (mxx <= mnn + i - st[t] - 1)
        continue;
      else
        flag = 1;
      if (flag) break;
    }
    ans += flag;
  }
  printf("%d\n", ans);
  return 0;
}
