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