#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, ans = 0, cnt = 0, i = 0;
  cin >> n >> k;
  string s;
  cin >> s;
  int ch[26];
  char c;
  memset(ch, 0, sizeof(ch));
  for (int i = 0; i < k; i++) {
    cin >> c;
    ch[c - 'a'] = 1;
  }
  for (int i = 0; i < n;) {
    if (ch[s[i] - 'a'] == 0) {
      i++;
    } else {
      cnt = 0;
      while (i < n and ch[s[i] - 'a'] == 1) {
        cnt++;
        i++;
      }
      ans += cnt * (cnt + 1) / 2;
    }
  }
  cout << ans << "\n";
  return 0;
}
