#include <bits/stdc++.h>
using namespace std;
int n, k, num[200005], len;
long long ans;
char s[200005];
int main() {
  cin >> n >> k;
  scanf("%s", s + 1);
  for (int i = 1; i <= k; i++) {
    char c;
    cin >> c;
    num[c - 'a' + 1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (num[s[i] - 'a' + 1]) {
      len++;
    } else {
      ans += (long long)(len + 1) * len / 2;
      len = 0;
    }
  }
  if (len != 0) {
    ans += (long long)len * (len + 1) / 2;
  }
  cout << ans;
}
