#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, ans(0);
  string s, c;
  cin >> n >> k >> s;
  cin.ignore();
  getline(cin, c, '\n');
  sort(c.begin(), c.end());
  vector<char> v;
  for (int i = 0; i < s.size(); i++) {
    bool b = false;
    for (int j = k - 1; j < c.size(); j++) {
      if (s[i] == c[j]) {
        v.push_back(s[i]);
        b = true;
      }
    }
    if (!b || i == n - 1) {
      long long x = v.size();
      ans += (x * (x + 1)) / 2;
      v.clear();
    }
  }
  cout << ans << endl;
}
