#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  unordered_set<char> chars;
  char tmp;
  for (int i = 0; i < k; i++) cin >> tmp, chars.insert(tmp);
  long long counter = 0;
  long long ans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (chars.count(s[i]) == 0) {
      ans += (counter * (counter + 1)) / 2;
      counter = 0;
    } else
      counter++;
  }
  ans += ((counter + 1) * counter) / 2;
  cout << ans;
}
