#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char ch;
  int A[1000001];
  memset(A, 1000001 - 1, 0);
  for (int i = 0; i < k; i++) {
    cin >> ch;
    A[ch - 'a'] = 1;
  }
  long long int ans = 0, x = -1;
  for (int i = 0; i < s.length(); i++) {
    if (A[s[i] - 'a']) {
      ans += i - x;
    } else
      x = i;
  }
  cout << ans;
  return 0;
}
