#include <bits/stdc++.h>
const int MAXN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f;
using namespace std;
int a[26];
int main() {
  int n, k;
  char z;
  cin >> n >> k;
  string s;
  cin >> s;
  for (int i = 0; i < k; ++i) {
    cin >> z;
    a[z - 'a'] = 1;
  }
  long long l = 0, ans = 0;
  for (long long i = 0; i < s.length(); ++i) {
    if (!a[s[i] - 'a']) {
      ans += (i - l) * (i - l + 1) / 2;
      l = i + 1;
    }
  }
  if (l != s.length()) ans += (s.length() - l) * (s.length() - l + 1) / 2;
  cout << ans << "\n";
  return 0;
}
