#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  long long a[26] = {0};
  for (long long i = 1; i <= k; i++) {
    char lol;
    cin >> lol;
    long long x = (long long)(lol - 97);
    a[x]++;
  }
  long long prev = -1, ans = 0;
  for (long long i = 0; i < n; i++) {
    if (a[s[i] - 'a'] != 0) {
      ans += (i - prev);
    } else {
      prev = i;
    }
  }
  cout << ans << endl;
  return 0;
}
