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