#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j;
  cin >> n >> k;
  string s;
  cin >> s;
  map<char, long long> m;
  for (i = 0; i < k; i++) {
    char c;
    cin >> c;
    m[c]++;
  }
  long long c = 0;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    if (m[s[i]] == 0) {
      if (c != 0) v.push_back(c);
      c = 0;
    } else
      c++;
  }
  if (c != 0) v.push_back(c);
  long long sum = 0;
  for (i = 0; i < v.size(); i++) {
    if (v[i] != 0) {
      sum = sum + (v[i] * (v[i] + 1)) / 2;
    }
  }
  cout << sum;
}
