#include <bits/stdc++.h>
using namespace std;
int vis[30];
string a;
int main() {
  int n, k;
  cin >> n >> k;
  cin >> a;
  for (int i = 0; i < k; i++) {
    char temp;
    cin >> temp;
    vis[temp - 'a'] = 1;
  }
  long long ans = 0, s = 0, flag = 1;
  for (long long i = 0; i < n; i++) {
    if (vis[a[i] - 'a']) {
      s++;
      continue;
    } else {
      ans += s * (s + 1) / 2;
      s = 0;
    }
  }
  ans += s * (s + 1) / 2;
  cout << ans << endl;
}
