#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, mo;
  cin >> n >> mo;
  string s;
  cin >> s;
  char c;
  map<char, long long int> m;
  for (long long int i = 0; i < mo; i++) {
    cin >> c;
    m[c]++;
  }
  unsigned long long int ans = 0;
  long long int prev = 0, curr = 0;
  for (long long int i = 0; i < n; i++) {
    curr = i;
    if (i == n - 1) {
      if (m[s[i]] == 0) {
        ans += ((curr - prev) * (curr - prev + 1)) / 2;
        prev = curr + 1;
      } else {
        ans += ((n - prev) * (n - prev + 1)) / 2;
      }
    }
    if (m[s[i]] == 0) {
      ans += ((curr - prev) * (curr - prev + 1)) / 2;
      prev = curr + 1;
    }
  }
  cout << ans << endl;
}
