#include <bits/stdc++.h>
using namespace std;
long long cnt[26];
int main() {
  long long n, m;
  scanf("%lld", &n), scanf("%lld", &m);
  string s;
  cin >> s;
  char c;
  for (long long i = 1; i <= m; i++) {
    cin >> c;
    cnt[c - 'a'] = 1;
  }
  long long x = 0, ans = 0;
  for (long long i = 0; i < n; i++) {
    if (cnt[s[i] - 'a'])
      x++;
    else {
      ans += (x * (x + 1)) / 2;
      x = 0;
    }
  }
  if (x) {
    ans += (x * (x + 1)) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
