#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
class AhoCorasick {
    vector<map<char, int>> G;
    vector<int> failure;
    vector<bool> is_match;
    int fresh_node() {
        const int res = G.size();
        G.resize(res+1);
        is_match.pb(false);
        return res;
    }
    int follow(int v, char c) const {
        while (v >= 0 && G[v].count(c) == 0) {
            v = failure[v];
        }
        return v < 0 ? 0 : G[v].find(c)->second;
    }
    void generate_trie(const vector<string>& patterns) {
        rep(i, patterns.size()) {
            int v = 0;
            each(c, patterns[i]) {
                if (G[v].count(c) == 0) {
                    G[v][c] = fresh_node();
                }
                v = G[v][c];
            }
            is_match[v] = true;
        }
        G.reserve(size());
        is_match.reserve(size());
    }
    void add_failure_edge() {
        queue<int> Q; Q.push(0);
        failure.reserve(size());
        failure.assign(size(), -1);
        while ( !Q.empty() ) {
            int v = Q.front(); Q.pop();
            each(p, G[v]) {
                char c; int to; tie(c, to) = p;
                Q.push(p.second);
                failure[to] = follow(failure[v], c);
            }
        }
    }
public:
    AhoCorasick(const vector<string>& patterns) : G(1), is_match(1, false) {
        generate_trie(patterns);
        add_failure_edge();
    }
    size_t size() const {
        return G.size();
    }
    pair<int, bool> find(int v, char c) const {
        bool res = false;
        v = follow(v, c);
        int now = v;
        while (now >= 0) {
            if (is_match[now]) res = true;
            now = failure[now];
        }
        return {v, res};
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    const ll n = s.size();
    ll m; cin >> m;
    vector<string> ptn(m); cin >> ptn;
    AhoCorasick ac(ptn);
    ll v = 0, ans = 0;
    rep(i, n) {
        auto result = ac.find(v, s[i]);
        if (result.second) {
            v = 0;
            ++ans;
        }
        else {
            v = result.first;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 12148