#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  while (cin >> n >> k) {
    string s;
    cin >> s;
    set<char> good;
    for (int i = 0; i < k; ++i) {
      char c;
      cin >> c;
      good.insert(c);
    }
    long long ans = 0;
    int i = 0;
    int j = 0;
    while (i < n) {
      while (j < n && good.count(s[j]) > 0) {
        j++;
      }
      long long x = j - i;
      ans += (x * (x + 1)) / 2;
      i = j + 1;
      j = i;
    }
    cout << ans << '\n';
  }
  return 0;
}
