#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  char ch[k];
  for (int i = 0; i < k; i++) cin >> ch[i];
  unsigned long long count = 0, sum = 0;
  for (long int i = 0; i < n; i++) {
    int flag = 0;
    for (int j = 0; j < k; j++) {
      if (str[i] == ch[j]) {
        flag = 1;
        break;
      }
    }
    if (flag == 1)
      count++;
    else {
      sum = sum + count * (count + 1) / 2;
      count = 0;
    }
  }
  sum = sum + count * (count + 1) / 2;
  cout << sum << endl;
}
