#include <bits/stdc++.h>
using namespace std;
long long a, b, i, j, n, k, l, subs, ans;
string s, s1, ss;
int main() {
  cin >> n >> k >> s;
  for (a = 0; a < k; ++a) {
    cin >> ss;
    s1 += ss;
  }
  for (a = 0; a < n; ++a) {
    for (b = 0; b < k; ++b)
      if (s[a] == s1[b]) {
        ++l;
        break;
      }
    if (l == 0) {
      ans += subs * (subs + 1) / 2;
      subs = 0;
    } else
      ++subs;
    l = 0;
  }
  ans += subs * (subs + 1) / 2;
  cout << ans;
}
