#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cerr.tie(0);
  ;
  long long q, k, ans = 0;
  cin >> q >> k;
  string second;
  cin >> second;
  map<char, int> mp;
  for (int i = 0; i < k; i++) {
    char c;
    cin >> c;
    mp[c]++;
  }
  long long temp = 0;
  for (int i = 0; i < second.size(); i++) {
    if (mp[second[i]] == 1)
      temp++;
    else {
      ans += ((temp) * (temp + 1)) / 2;
      temp = 0;
    }
  }
  ans += ((temp) * (temp + 1)) / 2;
  cout << ans;
}
