#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

struct RollingHash {
    const int base = 9973;
    const int mod[2] = {999999937, 1000000007};
    vector<int> s;
    vector<ll> hash[2], pow[2];

    template<class S>
    RollingHash(const S &s) {
        int n = s.size();
        for (int id = 0; id < 2; ++id) {
            hash[id].assign(n+1, 0);
            pow[id].assign(n+1, 1);
            for (int i = 0; i < n; ++i) {
                hash[id][i+1] = (hash[id][i] * base + s[i]) % mod[id];
                pow[id][i+1] = pow[id][i] * base % mod[id];
            }
        }
    }

    // get hash of s[l:r)
    pair<ll,ll> get(int l, int r) {
        ll ret[2];
        for (int id = 0; id < 2; ++id) {
            ret[id] = hash[id][r] - hash[id][l] * pow[id][r - l] % mod[id];
            if (ret[id] < 0) ret[id] += mod[id];
        }
        return { ret[0], ret[1] };
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

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

        vector<string> e(n);
        vector<pair<ll,ll>> ehash(n);
        REP(i, n) {
            cin >> e[i];
            ehash[i] = RollingHash(e[i]).get(0, e[i].size());
        }

        string t;
        REP(i, m) {
            string s; cin >> s;
            t += s;
        }
        RollingHash thash(t);

        vvi valid(t.size(), vi(n));
        REP(i, t.size()) {
            REP(j, n) {
                valid[i][j] = i + e[j].size() <= t.size() and
                    thash.get(i, i+e[j].size()) == ehash[j];
            }
        }

        vvi dp(t.size()+1, vi(1<<n));
        REP(i, t.size()) dp[i][0] = 1;
        REP(i, t.size()) {
            REP(s, 1<<n) {
                if (dp[i][s] == 0) continue;
                REP(j, n) {
                    if (s >> j & 1) continue;
                    if (i + e[j].size() <= t.size()) {
                        dp[i + e[j].size()][s | 1<<j] |= valid[i][j];
                    }
                }
            }
        }

        ll ans = 0;
        REP(i, t.size()) {
            if (dp[i+1][(1<<n)-1]) ++ans;
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 83572