#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  bool arr[26] = {false};
  for (int i = 0; i < k; i++) {
    char c;
    cin >> c;
    arr[c - 'a'] = true;
  }
  long long ans = 0;
  long long co = 0;
  for (int i = 0; i < n; i++) {
    int x;
    x = s[i] - 'a';
    if (arr[s[i] - 'a'] == true)
      co++;
    else {
      ans += (co * (co + 1)) / 2;
      co = 0;
    }
  }
  ans += (co * (co + 1)) / 2;
  cout << ans;
}
