Problem: G： 検閲により置換 (Censored String)

Problem Statement

You are given the string S, and the set of strings \mathcal P whose size is N. Now we consider applying the following operation to S:

* Choose exactly one character in S, and replace it with '*'.



Let s_i be a i-th character of S, S_{ij} be a consecutive substring in S such that  S = s_i s_{i+1} $\cdots$  s_j, and p_k as the k-th string of P. Your task is to calculate the minimum number of operations for satisfying the following condition.

* For all pairs (S_{ij}, p_k), it is satisfied that S_{ij} \neq p_k.



Input

An input is given in the following format.


S
N
p_1
p_2
$\vdots$
p_N


* In line 1, you are given the string S.
* In line 2, given an integer N. N means the size of P.
* From line 3 to the end, given p_i, the i-th string of P.



Constraints

* 1 \leq |S| \leq 10^5
* 1 \leq N \leq 10^5
* 1 \leq |p_1| + |p_2| +  $\cdots$  + |p_N| \leq 10^5
* If i \neq j, it is guaranteed that p_i \neq p_j
* S, and p_i include lowercase letters only



Output

Print the minimum number of operations in one line.

Sample Input 1


brainfuck
1
fuck


Sample Output 1


1

For example, if you change "brainfuck" into "brainf*ck", you can satisfy the condition. You have to perform operation at least once, and it is the minimum value.

Sample Input 2


aaa
1
a


Sample Output 2


3

You have to operate for all characters.

Sample Input 3


hellshakeyano
3
hell
shake
key


Sample Output 3


2

In this case, for example, if you change "hellshakeyano" into "h*llsha*eyano", you can satisfy the condition. Notice if you replace one character, it might happen that several strings in the set P, which appear as the consecutive substring of S, simultaneously disappear.





Example

Input

brainfuck
1
fuck


Output

1

Solution (in CPP):

Solution:
#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;
}