#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream& operator<<(ostream& s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, vector<T> t) {
  for (int(i) = 0; (i) < (((int)(t.size()))); ++(i)) s << t[i] << " ";
  return s;
}
template <class Aug>
struct ITree {
  inline static Aug plus(Aug a1, Aug a2) { return min(a1, a2); }
  static const Aug identity = 1000000000;
  int leftend, rightend;
  Aug* state;
  ITree(int _leftend, int _rightend) : leftend(_leftend), rightend(_rightend) {
    int pot = 1;
    while (pot <= _rightend - _leftend + 5) pot <<= 1;
    pot <<= 1;
    state = new Aug[pot + 20];
    for (int(i) = 0; (i) < (pot + 20); ++(i)) state[i] = identity;
  }
  void set_aux(int x, Aug ile, int v, int from, int to) {
    if (from == to) {
      state[v] = ile;
      return;
    }
    int mid = (from + to) / 2;
    if (x <= mid)
      set_aux(x, ile, 2 * v + 1, from, mid);
    else
      set_aux(x, ile, 2 * v + 2, mid + 1, to);
    state[v] = plus(state[2 * v + 1], state[2 * v + 2]);
  }
  void set(int x, Aug ile) { set_aux(x, ile, 0, leftend, rightend); }
  Aug sumofaugsoverkeyssmallerorequal_aux(int x, int v, int from, int to) {
    if (x < from) return identity;
    if (from == to) return state[v];
    int mid = (from + to) / 2;
    if (x >= mid + 1)
      return plus(state[2 * v + 1], sumofaugsoverkeyssmallerorequal_aux(
                                        x, 2 * v + 2, mid + 1, to));
    return sumofaugsoverkeyssmallerorequal_aux(x, 2 * v + 1, from, mid);
  }
  Aug sumofaugsoverkeysbiggerorequal_aux(int x, int v, int from, int to) {
    if (x > to) return identity;
    if (from == to) return state[v];
    int mid = (from + to) / 2;
    if (x <= mid)
      return plus(sumofaugsoverkeysbiggerorequal_aux(x, 2 * v + 1, from, mid),
                  state[2 * v + 2]);
    return sumofaugsoverkeysbiggerorequal_aux(x, 2 * v + 2, mid + 1, to);
  }
  Aug sumofaugsoverkeyssmallerorequal(int x) {
    return sumofaugsoverkeyssmallerorequal_aux(x, 0, leftend, rightend);
  }
  Aug sumofaugsoverkeysbiggerorequal(int x) {
    return sumofaugsoverkeysbiggerorequal_aux(x, 0, leftend, rightend);
  }
  Aug sumofaugsoverkeysbetween_aux(int x, int y, int v, int from, int to) {
    if (y < from) return identity;
    if (x > to) return identity;
    if (from == to) return state[v];
    int mid = (from + to) / 2;
    if (y < mid + 1)
      return sumofaugsoverkeysbetween_aux(x, y, 2 * v + 1, from, mid);
    if (x > mid)
      return sumofaugsoverkeysbetween_aux(x, y, 2 * v + 2, mid + 1, to);
    return plus(sumofaugsoverkeysbiggerorequal_aux(x, 2 * v + 1, from, mid),
                sumofaugsoverkeyssmallerorequal_aux(y, 2 * v + 2, mid + 1, to));
  }
  Aug sumofaugsoverkeysbetween(int x, int y) {
    if (x > y) return identity;
    return sumofaugsoverkeysbetween_aux(x, y, 0, leftend, rightend);
  }
};
namespace karkkainen {
inline bool leq(int a1, int a2, int b1, int b2) {
  return (a1 < b1 || (a1 == b1 && a2 <= b2));
}
inline bool leq(int a1, int a2, int a3, int b1, int b2, int b3) {
  return (a1 < b1 || (a1 == b1 && leq(a2, a3, b2, b3)));
}
static void radixPass(int* a, int* b, int* r, int n, int K) {
  vector<int> c(K + 1, 0);
  for (int(i) = 0; (i) < (n); ++(i)) c[r[a[i]]]++;
  int sum = 0;
  for (int(i) = (0); (i) <= (K); ++i) {
    int t = c[i];
    c[i] = sum;
    sum += t;
  }
  for (int(i) = 0; (i) < (n); ++(i)) b[c[r[a[i]]]++] = a[i];
}
void suffixArray(int* s, int* SA, int n, int K) {
  int n0 = (n + 2) / 3, n1 = (n + 1) / 3, n2 = n / 3, n02 = n0 + n2;
  int* s12 = new int[n02 + 3];
  s12[n02] = s12[n02 + 1] = s12[n02 + 2] = 0;
  int* SA12 = new int[n02 + 3];
  SA12[n02] = SA12[n02 + 1] = SA12[n02 + 2] = 0;
  int* s0 = new int[n0];
  int* SA0 = new int[n0];
  for (int i = 0, j = 0; i < n + (n0 - n1); i++)
    if (i % 3 != 0) s12[j++] = i;
  radixPass(s12, SA12, s + 2, n02, K);
  radixPass(SA12, s12, s + 1, n02, K);
  radixPass(s12, SA12, s, n02, K);
  int name = 0, c0 = -1, c1 = -1, c2 = -1;
  for (int(i) = 0; (i) < (n02); ++(i)) {
    if (s[SA12[i]] != c0 || s[SA12[i] + 1] != c1 || s[SA12[i] + 2] != c2) {
      name++;
      c0 = s[SA12[i]];
      c1 = s[SA12[i] + 1];
      c2 = s[SA12[i] + 2];
    }
    if (SA12[i] % 3 == 1) {
      s12[SA12[i] / 3] = name;
    } else {
      s12[SA12[i] / 3 + n0] = name;
    }
  }
  if (name < n02) {
    suffixArray(s12, SA12, n02, name);
    for (int(i) = 0; (i) < (n02); ++(i)) s12[SA12[i]] = i + 1;
  } else {
    for (int(i) = 0; (i) < (n02); ++(i)) SA12[s12[i] - 1] = i;
  }
  for (int i = 0, j = 0; i < n02; ++i)
    if (SA12[i] < n0) s0[j++] = 3 * SA12[i];
  radixPass(s0, SA0, s, n0, K);
  int p = 0, t = n0 - n1;
  for (int(k) = 0; (k) < (n); ++(k)) {
    int i = (SA12[t] < n0 ? SA12[t] * 3 + 1 : (SA12[t] - n0) * 3 + 2);
    int j = SA0[p];
    if (SA12[t] < n0 ? leq(s[i], s12[SA12[t] + n0], s[j], s12[j / 3])
                     : leq(s[i], s[i + 1], s12[SA12[t] - n0 + 1], s[j],
                           s[j + 1], s12[j / 3 + n0])) {
      SA[k] = i;
      t++;
      if (t == n02) {
        for (k++; p < n0; p++, k++) SA[k] = SA0[p];
      }
    } else {
      SA[k] = j;
      p++;
      if (p == n0) {
        for (k++; t < n02; t++, k++)
          SA[k] = (SA12[t] < n0 ? SA12[t] * 3 + 1 : (SA12[t] - n0) * 3 + 2);
      }
    }
  }
  delete[] s12;
  delete[] SA12;
  delete[] SA0;
  delete[] s0;
}
};  // namespace karkkainen
struct SuffixArray {
  int *sa, *lcp;
  ITree<int> tr;
  SuffixArray(const string& t, bool with_lcp = 0)
      : tr(0, ((int)(t.size())) - 1) {
    int n = ((int)(t.size()));
    if (n <= 1) {
      sa = new int[5];
      sa[0] = 0;
    } else {
      int* arr = new int[n + 3];
      sa = new int[n + 3];
      for (int(i) = 0; (i) < (n); ++(i)) arr[i] = t[i];
      arr[n] = arr[n + 1] = arr[n + 2] = 0;
      karkkainen::suffixArray(arr, sa, n, *max_element(arr, arr + n));
      delete[] arr;
    }
    for (int(i) = 0; (i) < (n); ++(i)) tr.set(i, sa[i]);
  }
};
char buf[100006];
int n;
vector<int> getBest(SuffixArray& a, string& s, string& t) {
  int m = ((int)(t.size())), from = 0, to = n - 1;
  vector<int> res(m, -1);
  for (int(j) = 0; (j) < (m); ++(j)) {
    int b1 = -1, f1 = from, t1 = to;
    while (f1 <= t1) {
      int mid = (f1 + t1) / 2;
      int ind = j + a.sa[mid];
      bool ok;
      if (ind >= n) {
        ok = 1;
      } else {
        if (s[ind] <= t[j])
          ok = 1;
        else
          ok = 0;
      }
      if (ok) {
        b1 = mid;
        f1 = mid + 1;
      } else {
        t1 = mid - 1;
      }
    }
    int b2 = n + 600, f2 = from, t2 = to;
    while (f2 <= t2) {
      int mid = (f2 + t2) / 2;
      int ind = j + a.sa[mid];
      bool ok;
      if (ind >= n) {
        ok = 0;
      } else {
        if (s[ind] >= t[j])
          ok = 1;
        else
          ok = 0;
      }
      if (ok) {
        b2 = mid;
        t2 = mid - 1;
      } else {
        f2 = mid + 1;
      }
    }
    if (b2 > b1) return res;
    from = b2;
    to = b1;
    int rmq = a.tr.sumofaugsoverkeysbetween(from, to);
    res[j] = rmq;
  }
  return res;
}
int main() {
  scanf("%s", buf);
  string s = buf;
  n = ((int)(s.size()));
  SuffixArray a1(s);
  string srev = s;
  reverse(srev.begin(), srev.end());
  SuffixArray a2(srev);
  int res = 0;
  int(testow);
  scanf("%d", &(testow));
  while (testow--) {
    scanf("%s", buf);
    string t(buf);
    string trev = t;
    reverse(trev.begin(), trev.end());
    int m = ((int)(t.size()));
    if (m == 1) continue;
    vector<int> best1 = getBest(a1, s, t), best2 = getBest(a2, srev, trev);
    if (best1[m - 1] != -1) {
      ++res;
    } else {
      bool ok = 0;
      for (int(i) = 0; (i) < (m - 1); ++(i)) {
        int a = best1[i];
        int b = best2[m - 2 - i];
        if (a == -1 || b == -1) continue;
        b = n - 1 - b;
        if (b - a + 1 >= m) ok = 1;
      }
      if (ok) ++res;
    }
  }
  pisz(res);
}
