#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long sz, q, cur, ans, cnt[100];
string s;
char c;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(30);
  cerr.precision(7);
  ;
  cin >> sz >> q >> s;
  while (q--) {
    cin >> c;
    cnt[c - 'a'] = 1;
  }
  for (int i = 0; i < s.size(); i++) {
    if (cnt[s[i] - 'a'] == 1) {
      cur++;
    } else {
      ans += (cur * (cur + 1LL)) / 2LL;
      cur = 0;
    }
  }
  ans += (cur * (cur + 1LL)) / 2LL;
  cout << ans;
  return 0;
}
