#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long MAX = 1e12;
int main() {
  string s;
  int n, k;
  cin >> n >> k;
  set<char> aval_char;
  aval_char.clear();
  cin >> s;
  for (int i = 0; i < k; i++) {
    char c;
    cin >> c;
    aval_char.insert(c);
  }
  long long tol_subs = 0;
  int start_index = 0;
  for (int i = 0; i < n;) {
    if (!aval_char.count(s[i])) {
      int len = i - start_index;
      tol_subs += 1ll * len * (len + 1) / 2;
      while (i < n && !aval_char.count(s[i])) i++;
      start_index = i;
    } else
      i++;
  }
  if (aval_char.count(s[n - 1])) {
    int len = n - start_index;
    tol_subs += 1ll * len * (len + 1) / 2;
  }
  cout << tol_subs;
  return 0;
}
