#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<char> str(k);
  for (long long int i = 0; i < k; i++) cin >> str[i];
  long long int ct = 0;
  unordered_set<char> set1;
  for (long long int i = 0; i < k; i++) set1.insert(str[i]);
  long long int start = 0;
  for (long long int i = 0; i < n; i++) {
    if (set1.find(s[i]) == set1.end()) {
      long long int len = i - start;
      ct += (len * (len + 1)) / 2;
      start = i + 1;
    }
  }
  if (n - start != 0) {
    long long int len = n - start;
    ct += (len * (len + 1)) / 2;
  }
  cout << ct;
  return 0;
}
