#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string s;
cin>>s;
int n;
cin>>n;
long sum=0;
while(n--)
{
string test;
cin>>test;
sort(test.begin(),test.end());
long m=s.size()-test.size()+1;
long len=m;
while(m--)
{
string::iterator beg,ed;
beg=s.begin()+len-m-1;
ed=beg+test.size();
string tmp(beg,ed);
sort(tmp.begin(),tmp.end());
if(tmp==test){
sum++;
}
//cout<<tmp<<endl;
}
}
cout<<sum<<endl;
return 0;
}