#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<deque>
#include<queue>
#include<complex>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>

using namespace std;

#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int n, m;
bool dp[5002][4100];
string e[20];

vector<int> g[5002];

/*
int *buildFail(const string &p){
  int M = p.length();
  int *fail = new int[M + 1];
  int j = fail[0] = -1;

  for(int i = 1; i <= M; i++){
    while(j >= 0 && p[j] != p[i - 1]){
      j = fail[j];
    }
    fail[i] = ++j;
  }
  return fail;
}

void match(int id, const string &t, const string &p, int *fail){
  int N = t.length(), M = p.length();

  for(int i = 0, k = 0; i < N; i++){
    while(k >= 0 && p[k] != t[i]){
      k = fail[k];
    }
    if(++k >= M){
      g[i - M + 1].push_back(id);
      k = fail[k];
    }
  }
}

void makeG(const string &s){
  for(int i = 0; i < s.length(); i++){
    g[i].clear();
  }

  int *fail = buildFail(s);
  for(int i = 0; i < n; i++){
    match(i, s, e[i], fail);
  }
}
*/

void makeG(const string &s){
  int len = s.length();

  for(int i = 0; i < len; i++){
    g[i].clear();
  }

  for(int i = 0; i < n; i++){
    int lene = e[i].length();

    for(int j = 0; j <= len - lene; j++){
      bool flg = true;

      for(int k = j; k < j + lene; k++){
        if(e[i][k - j] != s[k]){
          flg = false;
          break;
        }
      }

      if(flg){
        g[j].push_back(i);
      }
    }
  }
}

ll solve(const string &s){
  makeG(s);

  ll res = 0;
  int FIN = (1 << n) - 1;
  int len = s.length();

  memset(dp, 0, sizeof(dp));

  for(int i = 0; i < len; i++){
    dp[i][0] = true;

    for(int j = 0; j < (1 << n) - 1; j++){
      if(!dp[i][j]) continue;

      for(int k = 0; k < g[i].size(); k++){
        int to = g[i][k];

        if((j & (1 << to)) == 0){
          int ni = i + e[to].length();
          int nj = (j | (1 << to));
          dp[ni][nj] = true;
        }
      }
    }
  }

  for(int i = 0; i <= len; i++){
    //trueツつェツ陛環づ個値ツ？ -> trueツづ?づ債づ按つュ1ツづーツ堕ォツつオツつアツづ楪づヲツつ、ツづ可つオツつス
    if(dp[i][FIN]){
      res++;
    }
  }

  return res;
}

int main(){
  while(cin >> n >> m, n || m){
    for(int i = 0; i < n; i++){
      cin >> e[i];
    }

    string s = "";

    for(int i = 0; i < m; i++){
      string ts;
      cin >> ts;
      s += ts;
    }

    cout << solve(s) << endl;
  }
}