#include #include #include #include #include ///#define MOD 1000000007 ///#define MOD2 1000000009 using namespace std; int n, q; char clown[500010]; char words[20][5010]; int wordsSize[20]; int ans[20]; void input() { freopen("clown.in", "r", stdin); scanf("%s", clown); scanf("%d", &q); for (int i = 0; i < q; i++) { scanf("%s", words[i]); wordsSize[i] = strlen(words[i]); } n = strlen(clown); fclose(stdin); } bool checkWord(int wordInd, int startInd, int endInd) ///[start, end] { for (int i = startInd; i <= (startInd + endInd) / 2; i++) if ((words[wordInd][i - startInd] != clown[i]) || (words[wordInd][wordsSize[wordInd] - (i - startInd) - 1] != clown[endInd - (i - startInd)])) return false; return true; } void calculate() { for (int i = 0; i < q; i++) for (int j = 0; j <= n - wordsSize[i]; j++) if (checkWord(i, j, wordsSize[i] + j - 1)) ans[i]++; } void output() { freopen("clown.out", "w", stdout); for (int i = 0; i < q; i++) printf("%d\n", ans[i]); fclose(stdout); } int main() { input(); calculate(); output(); return 0; } /*! miraclesinmississippihonk 5 in i mi is motherfaygo nanananabatman 3 nana na an */