#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  set<char> ok;
  vector<char> v(k);
  for (auto &i : v) cin >> i, ok.insert(i);
  long long ans = 0;
  int c = 0;
  s += "@";
  for (auto i : s) {
    if (ok.find(i) != ok.end())
      ++c;
    else {
      ans += (long long)c * (c + 1) / 2;
      c = 0;
    }
  }
  cout << ans << "\n";
  return 0;
}
