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