#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, k;
  string s;
  cin >> n >> k >> s;
  char ch;
  long long arr[26];
  memset(arr, 0, sizeof(arr));
  for (long long i = 0; i < k; i++) {
    cin >> ch;
    arr[ch - 97] = 1;
  }
  for (long long i = 0; i < n; i++) {
    if (arr[s[i] - 97] != 1) {
      s[i] = '1';
    }
  }
  s += '1';
  long long ans = 0;
  long long sum = 0;
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] == '1') {
      ans += sum * (sum + 1) / 2;
      sum = 0;
    } else {
      sum++;
    }
  }
  cout << ans;
  return 0;
}
