#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
int main() {
  long long n, i, d = 0, a = 0, k, l, j;
  cin >> n >> k;
  string s;
  cin >> s;
  char c;
  long long arr[26];
  for (i = 0; i < 26; i++) arr[i] = 0;
  for (i = 0; i < k; i++) {
    cin >> c;
    arr[c - 97] = 1;
  }
  for (i = 0; i < n; i++) {
    l = 0;
    for (j = 0; j < 26; j++) {
      if (arr[j] == 0 && s[i] == j + 97) {
        l = 1;
        break;
      }
    }
    if (l) {
      a += (d * (d + 1)) / 2;
      d = 0;
    } else {
      d++;
    }
  }
  a += (d * (d + 1)) / 2;
  cout << a << endl;
  return 0;
}
