#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  static int x[27];
  int n, k;
  cin >> n >> k;
  cin >> s;
  for (int i = 0; i < k; i++) {
    char r;
    cin >> r;
    x[r - 'a'] = 1;
  }
  long long res = 0, tr = 0;
  for (int i = 0; s[i]; i++) {
    if (x[s[i] - 'a'])
      tr++;
    else {
      res += (tr * (tr + 1)) / 2;
      tr = 0;
    }
  }
  res += (tr * (tr + 1)) / 2;
  cout << res;
  return 0;
}
