#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define MAX_LEN	(5000)
#define MAX_N	(12)

/* global variables */

bool eoks[MAX_LEN][MAX_N];
bool eused[MAX_LEN + 1][1 << MAX_N];

string elms[MAX_N];
int elens[MAX_N];

/* main */

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if ((n | m) == 0) break;

    for (int i = 0; i < n; i++) {
      cin >> elms[i];
      elens[i] = elms[i].size();
    }

    string text;
    string line;

    for (int i = 0; i < m; i++) {
      cin >> line;
      text += line;
    }
    int tlen = text.size();

    int allbits = (1 << n) - 1;
  
    memset(eoks, false, sizeof(eoks));
    memset(eused, false, sizeof(eused));
  
    for (int pos = 0; pos < tlen; pos++)
      for (int k = 0; k < n; k++)
	if (text.substr(pos, elens[k]) == elms[k]) {
	  eoks[pos][k] = true;
	  eused[pos + elens[k]][1 << k] = true;
	}
    //p eused

    for (int pos = 0; pos < tlen; pos++) {
      for (int bits = 0; bits <= allbits; bits++) {
	if (! eused[pos][bits]) continue;

	for (int k = 0; k < n; k++) {
	  int bk = 1 << k;
	  int posk = pos + elens[k];
	  if (eoks[pos][k] && (bits & bk) == 0 && posk <= tlen)
	    eused[posk][bits | bk] = true;
	}
      }
    }

    int count = 0;
    for (int pos = 0; pos <= tlen; pos++)
      if (eused[pos][allbits]) count++;
  
    cout << count << endl;
  }

  return 0;
}