#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  long long int m;
  cin >> n >> m;
  string a;
  cin >> a;
  vector<string> v;
  string a1 = "";
  string b[m];
  long long int p = 0;
  long long int sum = 0;
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    v.push_back(b[i]);
  }
  for (int i = 0; i < n; i++) {
    a1 = a[i];
    if (count(v.begin(), v.end(), a1)) {
      p++;
    } else {
      sum += p * (p + 1) / 2;
      p = 0;
    }
  }
  sum += p * (p + 1) / 2;
  cout << sum << endl;
  return 0;
}
