#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, ALF = 27;
int n, k;
string s;
int cnt[N][ALF];
void print(int a) {
  for (int i = 0; i < ALF; i++) cout << ((a & (1 << i)) ? '1' : '0');
  cout << '\n';
}
int main() {
  cin >> n >> k;
  cin >> s;
  s = '#' + s;
  int a = 0;
  for (int i = 0; i < k; i++) {
    char x;
    cin >> x;
    a |= 1 << (x - 'a');
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < ALF; j++) cnt[i][j] = cnt[i - 1][j];
    cnt[i][s[i] - 'a']++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int l = i, r = n + 1;
    while (r - l > 1) {
      int m = (l + r) >> 1;
      int b = 0;
      for (int j = 0; j < ALF; j++)
        if (cnt[m][j] - cnt[i - 1][j] > 0) b |= 1 << j;
      if ((a & b) == b)
        l = m;
      else
        r = m;
    }
    int b = 0;
    for (int j = 0; j < ALF; j++)
      if (cnt[l][j] - cnt[i - 1][j]) b |= 1 << j;
    if ((a & b) == b) ans += l - i + 1;
  }
  cout << ans << '\n';
}
