#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<char> v;
  while (k--) {
    char x;
    cin >> x;
    v.push_back(x);
  }
  long long l = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (find(v.begin(), v.end(), s[i]) != v.end())
      l++;
    else {
      ans = ans + (l * (l + 1)) / 2;
      l = 0;
    }
  }
  ans = ans + (l * (l + 1)) / 2;
  cout << ans;
  return 0;
}
