#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;
typedef long long ll;
ll dp[32][1 << 12];

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		vector<string> patterns(n);
		for(int i = 0; i < n; ++i){ cin >> patterns[i]; }
		string text;
		for(int i = 0; i < m; ++i){
			string line;
			cin >> line;
			text += line;
		}
		const int length = text.size();
		vector<int> match(length);
		for(int i = 0; i < n; ++i){
			const int p = patterns[i].size();
			for(int j = 0; j + p <= length; ++j){
				int flag = 1;
				for(int k = 0; flag && k < p; ++k){
					if(text[j + k] != patterns[i][k]){ flag = 0; }
				}
				match[j] |= (flag << i);
			}
		}
		memset(dp, 0, sizeof(dp));
		ll answer = 0;
		for(int i = 0; i < length; ++i){
			const int cur = i & 31, next = (i - 1) & 31;
			for(int j = 0; j < (1 << n); ++j){ dp[next][j] = 0; }
			dp[cur][0] = 1;
			for(int j = 0; j + 1 < (1 << n); ++j){
				int mask = match[i] & ~j;
				while(mask != 0){
					const int shift = __builtin_ctz(mask);
					mask &= mask - 1;
					const int a = (i + patterns[shift].size()) & 31;
					const int b = j | (1 << shift);
					dp[a][b] += dp[cur][j];
				}
			}
			if(dp[(cur + 1) & 31][(1 << n) - 1]){ ++answer; }
		}
		cout << answer << endl;
	}
	return 0;
}