#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MAX = 1e5 + 10;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int a[100] = {0};
  for (long long i = 0; i < k; i++) {
    char ch;
    cin >> ch;
    a[ch - 'a'] = 1;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    int j = i;
    while (j < n && a[s[j] - 'a'] == 1) j++;
    ans += (j - i) * (j - i + 1) / 2;
    if (i != j) i = j - 1;
  }
  cout << ans;
}
