#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  string s;
  cin >> n >> k >> s;
  s = "{" + s + "{";
  long long a[30] = {0}, i, j = 0, b;
  long long ans = 0;
  char c;
  while (k--) {
    cin >> c;
    b = c - 'a';
    a[b]++;
  }
  for (i = 0; i <= n + 1; i++) {
    b = s[i] - 'a';
    if (!a[b]) {
      ans += (i - j) * (i - j - 1) / 2;
      j = i;
    }
  }
  cout << ans << endl;
  return 0;
}
