#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, p = "";
  int n, k;
  cin >> n >> k >> s;
  for (int i = 0; i < k; i++) {
    char c;
    cin >> c;
    p += c;
  }
  long long ans = 0;
  int len = 0;
  for (int i = 0; s[i]; i++) {
    if (strchr(p.c_str(), s[i])) {
      len++;
    } else {
      ans += 1LL * len * (len + 1) / 2;
      len = 0;
    }
  }
  ans += 1LL * len * (len + 1) / 2;
  cout << ans;
  return 0;
}
