#include using namespace std; using ll = long long; using ull = unsigned long long; template struct RollingHash { vector hashs, power; RollingHash() {} RollingHash(const string& s, ull base = 10007) { int sz = s.size(); hashs.assign(sz + 1, 0); power.assign(sz + 1, 0); power[0] = 1; for (int i = 0; i < sz; i++) { power[i + 1] = power[i] * base % mod; hashs[i + 1] = (hashs[i] * base) % mod + s[i]; if (hashs[i + 1] >= mod) hashs[i] -= mod; } } ull get(int l, int r) const { ull res = hashs[r] + mod - hashs[l] * power[r - l] % mod; if (res >= mod) res -= mod; return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); int m; cin >> m; RollingHash<> rhs(s); int ans = 0; for (int i = 0; i < m; i++) { string c; cin >> c; RollingHash<> rhc(c); int cl = c.size(); int cnt = 0; for (int i = 0; i + cl <= n; i++) { cnt += (rhs.get(i, i + cl) == rhc.get(0, cl)); } ans += cnt; } cout << ans << "\n"; return 0; }