#include <bits/stdc++.h>
using namespace std;
long long int n, k;
int working[300];
char ch;
char question[200005];
void init() {
  for (int i = 0; i < 300; i++) working[i] = 0;
}
int main() {
  cin >> n >> k;
  scanf("%s", question);
  init();
  for (int i = 0; i < k; i++) {
    cin >> ch;
    working[ch]++;
  }
  int i = 0;
  long long int res = 0;
  while (i < n) {
    long long int count = 0;
    if (i < n && working[question[i]] != 0) {
      while (i < n && working[question[i]] != 0) {
        i++;
        count++;
      }
    } else {
      i++;
    }
    res += ((count) * (count + 1)) / 2;
  }
  cout << res << endl;
  return 0;
}
