#include <bits/stdc++.h>
using namespace std;
string s;
bool ache[200];
int main() {
  char c;
  long long cnt, ans;
  int t, tc, i, k, n;
  cin >> n >> k;
  cin >> s;
  for (i = 0; i < k; i++) {
    cin >> c;
    ache[c] = true;
  }
  for (i = 0, cnt = 0, ans = 0LL; i < n; i++) {
    if (ache[s[i]]) {
      cnt++;
    } else {
      ans += (cnt * (cnt + 1LL)) / 2LL;
      cnt = 0;
    }
  }
  ans += (cnt * (cnt + 1LL)) / 2LL;
  cout << ans << "\n";
  return 0;
}
