#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  string s, c;
  cin >> s;
  vector<int> v(26, 0);
  for (int i = 0; i < k; i++) {
    cin >> c;
    int idx = (int)(c[0] - 'a');
    v[idx] = 1;
  }
  long long ans = 0;
  long long prev = -1;
  for (long long i = 0; i < n; i++) {
    if (!v[s[i] - 'a']) {
      ans += (i - prev - 1) * (i - prev) / 2;
      prev = i;
    }
  }
  ans += (n - prev - 1) * (n - prev) / 2;
  cout << ans << endl;
}
