#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  set<char> fo;
  for (long long i = 0; i < k; i++) {
    char c;
    cin >> c;
    fo.insert(c);
  }
  s += '#';
  long long cur = 0, ans = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (fo.count(s[i])) {
      cur++;
    } else {
      ans += cur * (cur + 1) / 2;
      cur = 0;
    }
  }
  cout << ans;
  return 0;
}
