#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

namespace SuffixArray{
	template<class T>
	void induce(int N,const T s[],bool is[],int sa[],int lbase[],int K){
		int it[K+1];
		copy_n(lbase,K+1,it);
		rep(i,N+1){
			if(sa[i]>=1&&!is[sa[i]-1]){
				int c=s[sa[i]-1];
				sa[it[c]++]=sa[i]-1;
			}
		}
		copy_n(lbase,K+1,it);
		for(int i=N;i>0;i--){
			if(sa[i]>=1&&is[sa[i]-1]){
				int c=s[sa[i]-1];
				sa[--it[c+1]]=sa[i]-1;
			}
		}
	}
	template<class T>
	void SA(int N,const T s[],int sa[],int K){
		bool is[N+1];		//stype?
		int lcnt[K+1]={},scnt[K+1]={};
		is[N]=1;
		for(int i=N-1;i>=0;i--){
			if(i==N-1||s[i]>s[i+1]) is[i]=0;
			else if(s[i]<s[i+1]) is[i]=1;
			else is[i]=is[i+1];
			if(!is[i]) lcnt[(int)s[i]]++;
			else scnt[(int)s[i]]++;
		}
		vector<int> v;		//LMSs
		int lms[N+1];
		fill_n(lms,N+1,-1);
		int c=0;
		rep1(i,N-1){
			if(!is[i-1]&&is[i]){
				lms[i]=c++;
				v.pb(i);
			}
		}
		int lbase[K+1],sbase[K+1];
		lbase[0]=1,sbase[0]=1+lcnt[0];
		rep1(i,K){
			lbase[i]=sbase[i-1]+scnt[i-1];
			sbase[i]=lbase[i]+lcnt[i];
		}
		if(!v.empty()){
			vector<int> v2=v;
			int it[K+1];			//iterate
			copy_n(sbase,K+1,it);
			fill_n(sa,N+1,-1);
			sa[0]=N;
			rep(i,v.size()){
				int c=s[v[i]];
				sa[it[c]++]=v[i];
			}
			induce(N,s,is,sa,lbase,K);
			int c=0;
			rep1(i,N) if(lms[sa[i]]>=0) v[c++]=sa[i];
			int s2[v.size()],sa2[v.size()+1];
			c=0;
			s2[lms[v[0]]]=0;
			for(int i=1;i<(int)v.size();i++){
				int l=v[i-1],r=v[i];
				while(true){
					if(s[l]!=s[r]){
						c++;
						break;
					}
					l++,r++;
					if(lms[l]>=0||lms[r]>=0){
						if(lms[l]<0||lms[r]<0) c++;
						break;
					}
				}
				s2[lms[v[i]]]=c;
			}
			SA(v.size(),s2,sa2,c);
			rep1(i,v.size()) v[i-1]=v2[sa2[i]];
		}
		int it[K+1];
		copy_n(sbase,K+1,it);
		fill_n(sa,N+1,-1);
		sa[0]=N;
		rep(i,v.size()){
			int c=s[v[i]];
			sa[it[c]++]=v[i];
		}
		induce(N,s,is,sa,lbase,K);
	}
	template<class T>
	void LCP(int N,const T s[],const int sa[],int lcp[]){
		int isa[N+1];
		rep(i,N+1) isa[sa[i]]=i;
		int h=0;
		rep(i,N){
			int j=sa[isa[i]-1];
			if(h>0) h--;
			for(;j+h<N&&i+h<N;h++){
				if(s[j+h]!=s[i+h]) break;
			}
			lcp[isa[i]-1]=h;
//			printf("lcp[%d]=%d\n",isa[i]-1,h);
		}
	}
}

struct segtree{
	using D = int;
	D inf = 1e9;

	int N;
	vector<D> val;

	segtree(){}
	segtree(int n){
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,inf);
	}
	segtree(const vector<D>& ds){
		int n = ds.size();
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,inf);
		rep(i,n) val[i+N] = ds[i];
		for(int i=N-1;i>0;i--) val[i] = min(val[i*2],val[i*2+1]);
	}
	void assign(int k,D d){
		k+=N;
		val[k]=d;
		k/=2;
		while(k){
			val[k] = min(val[k*2],val[k*2+1]);
			k/=2;
		}
	}
	D getmin(int a,int b){
		D res = inf;
		a+=N,b+=N;
		while(a<b){
			if(a&1) chmin(res,val[a++]);
			if(b&1) chmin(res,val[--b]);
			a/=2,b/=2;
		}
		return res;
	}
};
struct segtree2{		//set range min
	using D = int;
	D inf = 1e9;

	int N;
	vector<D> val;

	segtree2(){}
	segtree2(int n){
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,inf);
	}
	segtree2(const vector<D>& ds){
		int n = ds.size();
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,inf);
		rep(i,n) val[i+N] = ds[i];
		for(int i=N-1;i>0;i--) val[i] = min(val[i*2],val[i*2+1]);
	}
	D getval(int k){
		D res = inf;
		k+=N;
		while(k){
			chmin(res,val[k]);
			k/=2;
		}
		return res;
	}
	void changemin(int a,int b,D d){
		a+=N,b+=N;
		while(a<b){
			if(a&1){
				chmin(val[a],d);
				a++;
			}
			if(b&1){
				--b;
				chmin(val[b],d);
			}
			a/=2,b/=2;
		}
	}
};



string S;
int K;
vector<string> T;
vector<int> tind;
const int MX = 400000;
int sa[MX],lcp[MX],isa[MX];
int main(){
	cin>>S;
	cin>>K;
	T.resize(K);
	tind.resize(K);
	rep(i,K) cin>>T[i];

	string s = S;
	rep(i,K){
		s += '?';
		tind[i] = s.size();
		s += T[i];
	}
	SuffixArray::SA(s.size(),s.c_str(),sa,256);
	SuffixArray::LCP(s.size(),s.c_str(),sa,lcp);
	rep(i,s.size()+1) isa[sa[i]] = i;

	vector<int> _;
	rep(i,s.size()) _.pb(lcp[i]);
	segtree seg(_);
//	show(_);
	segtree2 seg2(s.size());

	rep(k,K){
		int len = T[k].size();
		int ind = tind[k];
		int x = isa[ind];

		int lb = -1,ub = x;
		while(ub-lb>1){
			int m = (ub+lb)/2;
			if(seg.getmin(m,x)>=len) ub = m;
			else lb = m;
		}
		int L = ub;

		lb = x,ub = s.size()+1;
		while(ub-lb>1){
			int m = (ub+lb)/2;
			if(seg.getmin(x,m)>=len) lb = m;
			else ub = m;
		}
		int R = lb+1;

		//[L,R)
//		show(k);
//		show(x);
//		show(L);
//		show(R);
//		printf("=-------\n");
		seg2.changemin(L,R,len);
	}

	int N = S.size();
	using P = pair<int,int>;
	vector<P> rans;
	rep(i,N){
		int x = isa[i];
		int len = seg2.getval(x);
		if(i+len>N) continue;
		rans.pb(P(i,i+len));
	}
//	show(rans);
	vector<P> nrans;
	for(P p:rans){
		while(!nrans.empty() && nrans.back().sc >= p.sc) nrans.pop_back();
		nrans.pb(p);
	}
	rans = nrans;

	int ans = 0;
	int x = -1;
	for(P p:rans){
		int l = p.fs, r = p.sc;
		if(x<l){
			ans++;
			x = r-1;
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 16704