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