#include <bits/stdc++.h>
using namespace std;
int b[26];
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c;
  for (int i = 0; i < k; i++) {
    cin >> c;
    b[c - 97]++;
  }
  long long count = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[s[i] - 97] == 0) {
      ans = ans + count * (count + 1) / 2;
      count = 0;
    } else {
      count++;
    }
  }
  cout << ans + count * (count + 1) / 2;
  return 0;
}
