#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  int b;
  cin >> num >> b;
  string s;
  cin >> s;
  int a[27];
  int c[num];
  for (int i = 0; i < num; i++) {
    c[i] = 0;
  }
  for (int i = 1; i <= 26; i++) {
    a[i] = 0;
  }
  for (int i = 0; i < b; i++) {
    char x;
    cin >> x;
    a[(int)x - 'a' + 1]++;
  }
  long long int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (a[(int)s[i] - 'a' + 1] > 0) {
      c[i] = 1;
    }
  }
  long long int count = 0;
  for (int i = 0; i < num; i++) {
    if (c[i] == 1) {
      count++;
    } else if (c[i] == 0) {
      ans += (count + 1) * (count) / 2;
      count = 0;
    }
  }
  ans += (count + 1) * (count) / 2;
  cout << ans << endl;
}
