#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
using ll = long long;
using ld = long double;
int n, k;
set<char> keys;
string s;
vector<ll> ns;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> s;
  for (int i = 0; i < k; i++) {
    char c;
    cin >> c;
    keys.insert(c);
  }
  int l = (int)s.length();
  int curn = 0;
  for (int i = 0; i < l; i++) {
    char c = s[i];
    if ((keys.find(c) != keys.end())) {
      curn++;
      continue;
    }
    if (curn > 0) ns.push_back(curn);
    curn = 0;
  }
  if (curn > 0) ns.push_back(curn);
  ll res = 0;
  for (ll elem : ns) {
    res += elem * (elem + 1ll) / 2ll;
  }
  cout << res << endl;
}
