#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  char c[200005];
  scanf("%s", c);
  int ok[26];
  memset(ok, 0, sizeof(ok));
  for (int i = 0; i < k; i++) {
    char cc;
    scanf(" %c", &cc);
    ok[cc - 'a'] = 1;
  }
  long long cnt = 0;
  long long ans = 0;
  for (int i = 0; c[i] != 0; i++) {
    if (ok[c[i] - 'a'])
      cnt++;
    else {
      ans += cnt * (cnt + 1) / 2;
      cnt = 0;
    }
  }
  ans += cnt * (cnt + 1) / 2;
  printf("%lld\n", ans);
}
