#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> c(26, 0);
  char temp;
  for (int i = 0; i < k; i++) cin >> temp, c[temp - 'a'] = 1;
  long long ans = 0;
  int i = 0;
  while (1) {
    long long count = 0;
    int j = i;
    while (j < n && c[s[j] - 'a'] == 1) j++;
    count = j - i;
    ans += ((count) * (count + 1)) / 2;
    i = j + 1;
    if (i >= n) break;
  }
  cout << ans << '\n';
  return 0;
}
