#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Aho{
  // failure link is slways 0.
  static const int FAIL = 0;
  static const int SIZE = 26 + 1;
  static int idx(char c){
	return c-'a' + 1;
  }
  
  struct Node{
	vector<Node*> chd;
	vector<int> accept;
	Node(){ chd.assign(SIZE, nullptr); }
	//~Node(){ FOR(i,1,SIZE){ delete chd[i]; chd[i] = nullptr; } }
  };

  Node* root;
  int kind;
  Aho(){ root = nullptr; }
  
  void build(const vector<string>& vs){
	//delete root;
	root = new Node();
	kind = vs.size();
	for(int i=0;i<kind;++i){
	  Node* crt = root;
	  for(char c: vs[i]){
		int ix = idx(c);
		if(!crt->chd[ix])
		  crt->chd[ix] = new Node();
		crt = crt->chd[ix];
	  }
	  crt->accept.push_back(i);
	}

	queue<Node*> q;
	for(int i=1;i<SIZE;++i)
	  if(root->chd[i]){
		root->chd[i]->chd[FAIL] = root;
		q.push(root->chd[i]);
	  }
	  else
		root->chd[i] = root;

	while(!q.empty()){
	  Node* t = q.front();
	  q.pop();
	  for(int i=1;i<SIZE;++i)
		if(t->chd[i]){
		  q.push(t->chd[i]);
		  Node* p = t->chd[FAIL];
		  while(!p->chd[i]) p = p->chd[FAIL];
		  t->chd[i]->chd[FAIL] = p->chd[i];
		  t->chd[i]->accept.insert(t->chd[i]->accept.end(), p->chd[i]->accept.begin(), p->chd[i]->accept.end());
		}
	}
  }

  int match(const string& s){
	int res = 0;
	Node* crt = root;
	for(char c: s){
	  int ix = idx(c);
	  while(!crt->chd[ix]) crt = crt->chd[FAIL];
	  crt = crt->chd[ix];

	  if(!crt->accept.empty()){
		++res;
		crt = root;
	  }
	}
	return res;
  }

  Node* next(Node* crt, char c){
	int ix = idx(c);
	while(!crt->chd[ix]) crt = crt->chd[FAIL];
	crt = crt->chd[ix];
	return crt;
  }
};

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;
  int N;
  cin >> N;

  VS vs(N);
  cin >> vs;

  Aho aho;
  aho.build(vs);

  cout << aho.match(S) << endl;
  
  return 0;
}


### Prompt

Please provide a CPP coded solution to the problem described below:

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>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct Aho{
  // failure link is slways 0.
  static const int FAIL = 0;
  static const int SIZE = 26 + 1;
  static int idx(char c){
	return c-'a' + 1;
  }
  
  struct Node{
	vector<Node*> chd;
	vector<int> accept;
	Node(){ chd.assign(SIZE, nullptr); }
	//~Node(){ FOR(i,1,SIZE){ delete chd[i]; chd[i] = nullptr; } }
  };

  Node* root;
  int kind;
  Aho(){ root = nullptr; }
  
  void build(const vector<string>& vs){
	//delete root;
	root = new Node();
	kind = vs.size();
	for(int i=0;i<kind;++i){
	  Node* crt = root;
	  for(char c: vs[i]){
		int ix = idx(c);
		if(!crt->chd[ix])
		  crt->chd[ix] = new Node();
		crt = crt->chd[ix];
	  }
	  crt->accept.push_back(i);
	}

	queue<Node*> q;
	for(int i=1;i<SIZE;++i)
	  if(root->chd[i]){
		root->chd[i]->chd[FAIL] = root;
		q.push(root->chd[i]);
	  }
	  else
		root->chd[i] = root;

	while(!q.empty()){
	  Node* t = q.front();
	  q.pop();
	  for(int i=1;i<SIZE;++i)
		if(t->chd[i]){
		  q.push(t->chd[i]);
		  Node* p = t->chd[FAIL];
		  while(!p->chd[i]) p = p->chd[FAIL];
		  t->chd[i]->chd[FAIL] = p->chd[i];
		  t->chd[i]->accept.insert(t->chd[i]->accept.end(), p->chd[i]->accept.begin(), p->chd[i]->accept.end());
		}
	}
  }

  int match(const string& s){
	int res = 0;
	Node* crt = root;
	for(char c: s){
	  int ix = idx(c);
	  while(!crt->chd[ix]) crt = crt->chd[FAIL];
	  crt = crt->chd[ix];

	  if(!crt->accept.empty()){
		++res;
		crt = root;
	  }
	}
	return res;
  }

  Node* next(Node* crt, char c){
	int ix = idx(c);
	while(!crt->chd[ix]) crt = crt->chd[FAIL];
	crt = crt->chd[ix];
	return crt;
  }
};

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;
  int N;
  cin >> N;

  VS vs(N);
  cin >> vs;

  Aho aho;
  aho.build(vs);

  cout << aho.match(S) << endl;
  
  return 0;
}


```