#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x;
  cin >> n >> x;
  string s;
  cin >> s;
  map<char, int> m;
  while (x--) {
    char c;
    cin >> c;
    m[c] = 1;
  }
  long long flag = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (m[s[i]] == 1 && i != n - 1) {
      flag++;
    } else if (m[s[i]] == 1 && i == n - 1) {
      flag++;
      sum += (flag * (flag + 1)) / 2;
    } else {
      sum += (flag * (flag + 1)) / 2;
      flag = 0;
    }
  }
  cout << sum << endl;
  return 0;
}
