#include <stdio.h>
#include <string.h>
#include <queue>
#define REP(i, n) for (i = 0; i < (n); i++)
#define REP1(i, n) for (i = 1; i <= (n); i++)
using namespace std;

const int CODE = (1 << 12) +10;
const int N = 5000 +10;

struct QUEUE {int n, code;};

bool f[CODE][N];

char a[20][20];
char s[N];

int ans, m, n;
int len[N];

queue <QUEUE> que;

bool ri()
{
	int i;

	ans = 0;
	memset(a, 0, sizeof(a));
	memset(f, false, sizeof(f));
	memset(s, 0, sizeof(s));
	scanf("%d%d", &n, &m);
	if (n == 0 && m == 0) return false;
	REP(i, n)
	{
		scanf("%s", a[i]);
		len[i] = strlen(a[i]);
	}
	while (m--) scanf("%s", s + (strlen(s)));
	m = strlen(s);
	return true;
}

bool same(int st, int x)
{
	int i;

	if (st + len[x] > m) return false;
	REP(i, len[x]) if (s[st + i] != a[x][i]) return false;
	return true;
}

void solve()
{
	int i, j;

	QUEUE v1, v2;

	while (!que.empty()) que.pop();
	REP(i, m)
		REP(j, n)
			if (same(i, j))
			{
				v1.n = i;
				v1.code = 1 << j;
				que.push(v1);
				f[1 << j][i] = true;
			}
	while (!que.empty())
	{
		v1 = que.front();
		que.pop();
		REP(i, n)
			if ((v1.code & (1 << i)) == 0 && v1.n - len[i] >= 0 && !f[v1.code | (1 << i)][v1.n - len[i]] && f[1 << i][v1.n - len[i]])
			{
				f[v1.code | (1 << i)][v1.n - len[i]] = true;
				v2.n = v1.n - len[i];
				v2.code = v1.code | (1 << i);
				que.push(v2);
			}
	}
	REP(i, m) ans += f[(1 << n) - 1][i];
}

int main()
{
	while (ri())
	{
		solve();
		printf("%d\n", ans);
	}
	return 0;
}