#include <bits/stdc++.h>
using namespace std;
int find(vector<char> &ch, char x) {
  vector<char>::iterator it;
  it = find(ch.begin(), ch.end(), x);
  if (it != ch.end()) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc = 1;
  string str;
  long long len, valid, i;
  while (tc--) {
    cin >> len >> valid;
    cin >> str;
    vector<char> ch(valid);
    for (auto &a : ch) cin >> a;
    ;
    long long cnt = 0, ans = 0;
    for (i = 0; i < (int)str.size(); i++) {
      if (find(ch, str[i]) == 0) {
        ans = ans + ((cnt * (cnt + 1)) / 2);
        cnt = 0;
      } else
        cnt++;
    }
    ans = ans + ((cnt * (cnt + 1)) / 2);
    cout << ans << '\n';
  }
  return 0;
}
