#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  char a;
  cin >> s;
  set<char> s1;
  for (int i = 0; i < k; i++) {
    cin >> a;
    s1.insert(a);
  }
  int ide[n], count = 0;
  for (int i = 0; i < n; i++) {
    for (auto it = s1.begin(); it != s1.end(); ++it) {
      if (s[i] == *it) {
        count++;
        break;
      }
    }
    if (count > 0) {
      ide[i] = 1;
    } else {
      ide[i] = 0;
    }
    count = 0;
  }
  vector<int> dp(n);
  if (ide[0] == 1) {
    dp[0] = 1;
  }
  for (int i = 1; i < n; i++) {
    if (ide[i] == 1) {
      dp[i] = dp[i] + dp[i - 1];
      dp[i]++;
    }
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = ans + dp[i];
  }
  cout << ans << endl;
  return 0;
}
