#include <iostream>
#include <string.h>
using namespace std;
char dic[15][60], text[5010], ch_t[5010];
int n, m, sum, ans;
int len[15],;
bool next[13][5010];
int s_l[(1<<12)];
void pre()
{
int i, j, k, l = strlen(text);
memset(next,0,sizeof(next));
for (j = 0; j < n; j ++)
for (i = 0; i <= l - len[j]; i ++)
{
for (k = 0; k < len[j] && dic[j][k] == text[i+k]; k ++);
next[j][i]=(dic[j][k]==0);
}
for(i = 1; i < (1<<n); i ++)
{
s_l[i] = 0;
for(j = 0; j < n; j ++)
if((1<<j) & i) s_l[i] += len[j];
}
}
int f[5001];
int main()
{
while(scanf("%d %d", &n, &m), n + m)
{
getchar();
sum = 0;
for(int i = 0; i < n; i ++)
{
gets(dic[i]);
len[i] = strlen(dic[i]);
sum += len[i];
}
strcpy(text,"");
for(int i = 0; i < m; i ++)
{
gets(ch_t);
strcat(text, ch_t);
}
pre();
//////////////////////////////////bfs/////////////////////////////////
int i, j, open, close, pos, cnt, l = strlen(text), st1, st2;
bool h[(1<<12)];
ans = 0;
for(i = 0; i <= l - sum; i ++)
{
open = 1;
for(j = 0; j < (1<<n); j ++) h[j] = false;
f[0] = 0;
for(close = 0;!h[(1<<n)-1] && close < open ;close++)
{
st1 = f[close];
for(j = 0; j < n; j ++)
if( !h[st1 |(1<<j)] && next[j][ i+s_l[st1]])
{
f[open] = (st1 | (1<<j));
h[ f[open ++] ] = true;
}
}
if(h[(1<<n)-1]) ans ++;
}
printf("%d\n", ans);
}
}