//#define _GLIBCXX_DEBUG #include #include using namespace std; using namespace atcoder; using mint = modint998244353; using ll = long long; using pii = pair; using pll = pair; using vs = vector; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; using vm = vector; using vvm = vector; using vpi = vector; using vvpi = vector; using vpl = vector; using vvpl = vector; const int inf = 1 << 30; const ll INF = 1LL << 58; #define rep(i,m,n) for (int i = m; i < (int)(n); i++) #define rrep(i,m,n) for (int i = m; i > (int)(n); i--) const ll b = 1e9 + 7; int main(){ vl B(10,1); rep(i,1,10) B[i] = B[i-1]*b; string s; cin >> s; int n = s.size(), m; cin >> m; ll ans = 0; rep(i,0,m){ string c; cin >> c; int l = c.size(); if (l > n) continue; ll hc = 0,hs = 0; rep(i,0,l){ hc += B[l-1-i]*c[i]; hs += B[l-1-i]*s[i]; } rep(i,0,n-l+1){ if (hc == hs) ++ans; if (i+l < n) hs = (hs - B[l-1]*s[i])*b + s[i+l]; } } cout << ans << endl; }