#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
template<typename State>
struct AhoCorasick {
	using string_t = typename State::string_t;
	using char_t = typename State::char_t;
	vector<State> pma;
	vector<int> lens;

	AhoCorasick(const vector<string_t> &str) : pma(0), lens(0) {
		pma.push_back(State());
		for (const string_t &s : str) {
			int t = 0;
			for (char_t c : s) {
				if (!pma[t].is_set(c)) {
					pma[t][c] = pma.size();
					pma.push_back(State());
				}
				t = pma[t][c];
			}
			pma[t].accept.push_back(lens.size());
			lens.push_back(s.size());
		}
		queue<int> que;
		for (char_t c = 'a'; c <= 'z'; c++) {
			if (pma[0].is_set(c)) {
				pma[pma[0][c]].fail = 0;
				que.push(pma[0][c]);
			}
			else {
				pma[0][c] = 0;
			}
		}
		while (!que.empty()) {
			int t = que.front();
			que.pop();
			for (char_t c = 'a'; c <= 'z'; c++) {
				if (pma[t].is_set(c)) {
					que.push(pma[t][c]);
					int r = pma[t].fail;
					while (!pma[r].is_set(c)) r = pma[r].fail;
					pma[pma[t][c]].fail = pma[r][c];
					for (int i : pma[pma[r][c]].accept) {
						pma[pma[t][c]].accept.push_back(i);
					}
				}
			}
		}
	}
	int next(int index, char_t c) {
		return pma[index].is_set(c) ?
			pma[index][c] :
			pma[index][c] = next(pma[index].fail, c);
	}
	vector<int> query(string_t &t) {
		int index = 0;
		vector<int> ret(lens.size(), -1);
		for (int i = 0; i < int(t.size()); ++i) {
			char_t c = t[i];
			index = next(index, c);
			for (int j : pma[index].accept) {
				if (ret[j] != -1) continue;
				ret[j] = i - lens[j] + 1;
			}
		}
		return ret;
	}
};

struct State {
	using string_t = string;
	using char_t = char;
	vector<int> edge;
	int fail;
	vector<int> accept;
	State() : fail(0), accept(0) { edge.resize(26); fill(begin(edge), end(edge), -1); }
	int& operator[] (char_t c) { return edge[c - 'a']; }
	const int& operator[] (char_t c) const { return edge[c - 'a']; }
	bool is_set(char_t c) { return edge[c - 'a'] >= 0; }
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n;
	cin >> n;
	vector<string> p(n);
	REP(i, n)cin >> p[i];
	AhoCorasick<State> ac(p);
	int index = 0;
	int ans = 0;
	REP(i, s.size()) {
		index=ac.next(index, s[i]);
		if (ac.pma[index].accept.size() != 0) {
			ans++;
			index = 0;
		}
	}
	cout << ans << endl;
}


### Prompt

Please create a solution in cpp to the following 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

### Response

```cpp
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
template<typename State>
struct AhoCorasick {
	using string_t = typename State::string_t;
	using char_t = typename State::char_t;
	vector<State> pma;
	vector<int> lens;

	AhoCorasick(const vector<string_t> &str) : pma(0), lens(0) {
		pma.push_back(State());
		for (const string_t &s : str) {
			int t = 0;
			for (char_t c : s) {
				if (!pma[t].is_set(c)) {
					pma[t][c] = pma.size();
					pma.push_back(State());
				}
				t = pma[t][c];
			}
			pma[t].accept.push_back(lens.size());
			lens.push_back(s.size());
		}
		queue<int> que;
		for (char_t c = 'a'; c <= 'z'; c++) {
			if (pma[0].is_set(c)) {
				pma[pma[0][c]].fail = 0;
				que.push(pma[0][c]);
			}
			else {
				pma[0][c] = 0;
			}
		}
		while (!que.empty()) {
			int t = que.front();
			que.pop();
			for (char_t c = 'a'; c <= 'z'; c++) {
				if (pma[t].is_set(c)) {
					que.push(pma[t][c]);
					int r = pma[t].fail;
					while (!pma[r].is_set(c)) r = pma[r].fail;
					pma[pma[t][c]].fail = pma[r][c];
					for (int i : pma[pma[r][c]].accept) {
						pma[pma[t][c]].accept.push_back(i);
					}
				}
			}
		}
	}
	int next(int index, char_t c) {
		return pma[index].is_set(c) ?
			pma[index][c] :
			pma[index][c] = next(pma[index].fail, c);
	}
	vector<int> query(string_t &t) {
		int index = 0;
		vector<int> ret(lens.size(), -1);
		for (int i = 0; i < int(t.size()); ++i) {
			char_t c = t[i];
			index = next(index, c);
			for (int j : pma[index].accept) {
				if (ret[j] != -1) continue;
				ret[j] = i - lens[j] + 1;
			}
		}
		return ret;
	}
};

struct State {
	using string_t = string;
	using char_t = char;
	vector<int> edge;
	int fail;
	vector<int> accept;
	State() : fail(0), accept(0) { edge.resize(26); fill(begin(edge), end(edge), -1); }
	int& operator[] (char_t c) { return edge[c - 'a']; }
	const int& operator[] (char_t c) const { return edge[c - 'a']; }
	bool is_set(char_t c) { return edge[c - 'a'] >= 0; }
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n;
	cin >> n;
	vector<string> p(n);
	REP(i, n)cin >> p[i];
	AhoCorasick<State> ac(p);
	int index = 0;
	int ans = 0;
	REP(i, s.size()) {
		index=ac.next(index, s[i]);
		if (ac.pma[index].accept.size() != 0) {
			ans++;
			index = 0;
		}
	}
	cout << ans << endl;
}


```