#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
long long read() {
  long long f = 1, x = 0;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return f * x;
}
int n, k;
char s[maxn], f[500];
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s", &s);
  for (int i = 0; i < k; i++) {
    char x;
    scanf("%s", &x);
    f[x]++;
  }
  long long ans = 0;
  int pos = 0;
  while (pos < n) {
    int num = 0, i;
    for (i = pos;; i++) {
      if (f[s[i]])
        num++;
      else
        break;
    }
    pos = i + 1;
    ans += 1ll * num * (num + 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
