#include <bits/stdc++.h>
using namespace std;
bool mark[1000000];
int main() {
  int n, k;
  char a;
  string s;
  scanf("%d%d", &n, &k);
  cin >> s;
  for (int i = 0; i < k; i++) {
    cin >> a;
    mark[a] = true;
  }
  long long sum = 0, cont = 0;
  for (int i = 0; i < n; i++) {
    if (!mark[s[i]] || i == n - 1) {
      if (mark[s[i]]) {
        cont++;
      }
      sum += (cont * (cont + 1)) / 2;
      cont = 0;
    } else {
      cont++;
    }
  }
  cout << sum << endl;
  return 0;
}
