#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  string s;
  cin >> s;
  vector<char> v;
  for (int i = 0; i < k; i++) {
    char x;
    cin >> x;
    v.push_back(x);
  }
  vector<long long> v2(n, 0);
  for (int i = 0; i < s.length(); i++) {
    for (int j = 0; j < v.size(); j++) {
      if (s[i] == v[j]) {
        if (i == 0) {
          v2[i] = 1;
        } else
          v2[i] = v2[i - 1] + 1;
        break;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    if (v2[i] == 0) {
      ans += (v2[i - 1] * (v2[i - 1] + 1)) / 2;
    }
  }
  if (v2[n - 1] != 0) {
    ans += (v2[n - 1] * (v2[n - 1] + 1)) / 2;
  }
  cout << ans;
}
