#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

enum Type{
    Unknown,
    TRUE,
    FALSE,
};

struct Node{
    int parent_id,children[26],suffix_link;
    bool finish_FLG;
};

struct Info{
    Info(int arg_node_id,int arg_ch){
        node_id = arg_node_id;
        ch = arg_ch;
    }

    int node_id,ch;
};

int index = 1,table[128];
char buf[NUM],P[NUM];
Node nodes[NUM];
Type memo[NUM];


int main(){

    for(int i = 0; i < 26; i++){
        table['a'+i] = i;
    }

    scanf("%s",buf);
    int length;
    for(length = 0; buf[length] != '\0'; length++);

    int root = 0;
    nodes[root].suffix_link = -1;

    for(int i = 0; i < NUM; i++){
        nodes[i].parent_id = -1;
        nodes[i].finish_FLG = false;
        for(int k = 0; k < 26; k++){
            nodes[i].children[k] = -1;
        }
    }

    int N;
    scanf("%d",&N);


    int tmp_ch,tmp_loc,parent_id,tmp_index;

    bool FLG;

    for(int loop = 0; loop < N; loop++){

        scanf("%s",P);

        tmp_index = 0;
        tmp_ch = table[P[tmp_index]];

        tmp_loc = root;
        tmp_index = 0;

        while(true){

            parent_id = tmp_loc;
            FLG = false;

            if(nodes[tmp_loc].children[tmp_ch] == -1){
                FLG = true;
                nodes[tmp_loc].children[tmp_ch] = index++;
            }
            tmp_loc = nodes[tmp_loc].children[tmp_ch];

            if(FLG){
                nodes[tmp_loc].parent_id = parent_id;
            }

            tmp_index++;

            if(P[tmp_index] == '\0'){
                nodes[tmp_loc].finish_FLG = true;
                break;
            }
            tmp_ch = table[P[tmp_index]];
        }
    }

    int node_id;
    queue<Info> MAKE_SL;
    for(int i = 0; i < 26; i++){
        if(nodes[root].children[i] != -1){
            node_id = nodes[root].children[i];
            nodes[node_id].suffix_link = root;
            for(int k = 0; k < 26; k++){
            	if(nodes[node_id].children[k] != -1){
            		MAKE_SL.push(Info(nodes[node_id].children[k],k));
            	}
            }
        }
    }

    while(!MAKE_SL.empty()){
        node_id = MAKE_SL.front().node_id;
        tmp_ch = MAKE_SL.front().ch;
        MAKE_SL.pop();

        for(int i = 0; i < 26; i++){
            if(nodes[node_id].children[i] != -1){
                MAKE_SL.push(Info(nodes[node_id].children[i],i));
            }
        }
        for(tmp_loc = nodes[nodes[node_id].parent_id].suffix_link; tmp_loc != root; tmp_loc = nodes[tmp_loc].suffix_link){
            if(nodes[tmp_loc].children[tmp_ch] != -1){
                break;
            }
        }

        if(tmp_loc == root){
            if(nodes[root].children[tmp_ch] != -1){
                nodes[node_id].suffix_link = nodes[root].children[tmp_ch];
            }else{
                nodes[node_id].suffix_link = root;
            }
        }else{
            nodes[node_id].suffix_link = nodes[tmp_loc].children[tmp_ch];
        }
    }

    for(int i = 0; i < index; i++){
        memo[i] = Unknown;
    }

    queue<int> Q;
    for(int i = 0; i < 26; i++){
        if(nodes[root].children[i] != -1){
            Q.push(nodes[root].children[i]);
        }
    }

    while(!Q.empty()){
        tmp_loc = Q.front();
        Q.pop();
        for(int i = 0; i < 26; i++){
            if(nodes[tmp_loc].children[i] != -1){
                Q.push(nodes[tmp_loc].children[i]);
            }
        }

        if(nodes[tmp_loc].finish_FLG){
            memo[tmp_loc] = TRUE;
        }else{
            for(int k = nodes[tmp_loc].suffix_link; k != root; k = nodes[k].suffix_link){
                if(memo[k] != Unknown){
                    memo[tmp_loc] = memo[k];
                    break;
                }
                if(nodes[k].finish_FLG){
                    memo[tmp_loc] = TRUE;
                    break;
                }
            }
            if(memo[tmp_loc] == Unknown){
                memo[tmp_loc] = FALSE;
            }
        }
    }

    int ans = 0;
    tmp_loc = root;

    for(int i = 0; i < length; i++){
        tmp_ch = table[buf[i]];

        if(nodes[tmp_loc].children[tmp_ch] != -1){
            tmp_loc = nodes[tmp_loc].children[tmp_ch];

            if(memo[tmp_loc] == TRUE){
                ans++;
                tmp_loc = root;
            }else{
                //Do nothing
            }

        }else{

            if(tmp_loc == root)continue;

            for(tmp_loc = nodes[tmp_loc].suffix_link; tmp_loc != root; tmp_loc = nodes[tmp_loc].suffix_link){
                if(nodes[tmp_loc].children[tmp_ch] != -1)break;
            }

            if(tmp_loc == root){
                if(nodes[tmp_loc].children[tmp_ch] != -1){
                    tmp_loc = nodes[tmp_loc].children[tmp_ch];
                    if(nodes[tmp_loc].finish_FLG){
                        ans++;
                        tmp_loc = root;
                    }
                }else{
                    //Do nothing
                }
            }else{
                tmp_loc = nodes[tmp_loc].children[tmp_ch];

                if(memo[tmp_loc] == TRUE){
                    ans++;
                    tmp_loc = root;
                }else{
                    //Do nothing
                }
            }
        }
    }

    printf("%d\n",ans);

    return 0;
}




Measured memory_bytes: 14884