#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string a;
  cin >> a;
  char b[m];
  for (int i = 0; i < m; i++) cin >> b[i];
  long long int p = 0;
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    int q = 0;
    for (int j = 0; j < m; j++) {
      if (a[i] == b[j]) {
        p++;
        break;
      } else
        q++;
    }
    if (q == m) {
      sum += p * (p + 1) / 2;
      p = 0;
    }
  }
  sum += p * (p + 1) / 2;
  cout << sum << endl;
  return 0;
}
