#include <bits/stdc++.h>
using namespace std;
unsigned long long counter(unsigned long long n) { return n * (n + 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<int, int> mp;
  char sc;
  unsigned long long clen, res;
  int n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  for (int i = 0; i < k; i++) {
    cin >> sc;
    mp[sc] = 1;
  }
  clen = 0;
  res = 0;
  for (int i = 0; str[i]; ++i) {
    if (mp[str[i]] == 0) {
      res += counter(clen);
      clen = 0;
    } else {
      clen++;
    }
  }
  cout << res + counter(clen) << endl;
  return 0;
}
