#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1e3 + 7;
int z[MAXN], pref[MAXN], m, sum[1007], occ[1007], suf[MAXN];
string s, t[107];
void upd_sum(int pos, int delta) {
  for (int i = pos; i <= 1000; i += (i & -i)) sum[i] += delta;
}
void upd_occ(int pos) {
  for (int i = pos; i <= 1000; i += (i & -i)) ++occ[i];
}
int get_sum(int pos) {
  int ret = 0;
  for (int i = pos; i >= 1; i -= (i & -i)) ret += sum[i];
  return ret;
}
int get_occ(int pos) {
  int ret = 0;
  for (int i = pos; i >= 1; i -= (i & -i)) ret += occ[i];
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s >> m;
  int n = (int)s.size();
  for (int i = 1; i <= m; ++i) cin >> t[i];
  int res = 0;
  for (int i = 1; i <= m; ++i) {
    string st = t[i] + s;
    int len = (int)st.size(), l = 0, r = -1;
    z[0] = len;
    for (int i = 1; i < len; ++i) {
      if (i > r) {
        l = r = i;
        while (r < len && st[r] == st[r - l]) ++r;
        z[i] = r - l, --r;
      } else if (z[i - l] < r - i + 1) {
        z[i] = z[i - l];
      } else {
        l = i;
        while (r < len && st[r] == st[r - l]) ++r;
        z[i] = r - l, --r;
      }
      if (i >= len - n) pref[i - len + n] = min(len - n - 1, z[i]);
    }
    st = "";
    for (int j = (int)t[i].size() - 1; j >= 0; --j) st.push_back(t[i][j]);
    for (int j = (int)s.size() - 1; j >= 0; --j) st.push_back(s[j]);
    len = (int)st.size(), l = 0, r = -1;
    z[0] = len;
    for (int i = 1; i < len; ++i) {
      if (i > r) {
        l = r = i;
        while (r < len && st[r] == st[r - l]) ++r;
        z[i] = r - l, --r;
      } else if (z[i - l] < r - i + 1) {
        z[i] = z[i - l];
      } else {
        l = i;
        while (r < len && st[r] == st[r - l]) ++r;
        z[i] = r - l, --r;
      }
      if (i >= len - n) suf[i - len + n] = min(len - n - 1, z[i]);
    }
    bool ok = 0;
    for (int i = 1; i <= 1000; ++i) sum[i] = occ[i] = 0;
    for (int i = 2 * n - len; i >= 0; --i) {
      int nxt = n - i - (len - n);
      if (suf[nxt] > 0) upd_occ(len - n - suf[nxt] + 1);
      if (get_occ(pref[i] + 1)) ok = 1;
    }
    if (ok) ++res;
  }
  cout << res;
  return 0;
}
