#include <bits/stdc++.h>
using namespace std;
void Sieve(int *prime, int n) {
  for (int i = 0; i < n; i++) {
    prime[i] = 0;
  }
  for (int i = 2; i < n; i++) {
    prime[i] = 1;
  }
  for (int i = 4; i < n; i += 2) {
    prime[i] = 0;
  }
  for (int i = 3; i < n; i++) {
    if (prime[i] == 1) {
      for (int j = i * i; j < n; j += i) {
        prime[j] = 0;
      }
    }
  }
  return;
}
void input() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  input();
  long long int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  map<char, int> m;
  for (int i = 0; i < k; i++) {
    char x;
    cin >> x;
    m.insert({x, 1});
  }
  long long int dp[n];
  long long int start = 0;
  if (m.find(s[0]) != m.end()) {
    dp[0] = 1;
    start = 0;
  } else {
    dp[0] = 0;
    start = 1;
  }
  for (long long int i = 1; i < n; i++) {
    char c = s[i];
    if (m.find(c) != m.end()) {
      long long int smallans = (i - start) + 1;
      dp[i] = dp[i - 1] + smallans;
    } else {
      dp[i] = dp[i - 1];
      start = i + 1;
    }
  }
  cout << dp[n - 1] << endl;
}
