#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c;
  bool b[26] = {};
  vector<long long> length;
  int count = 0;
  for (int i = 0; i < k; i++) {
    cin >> c;
    b[c - 'a'] = true;
  }
  for (int i = 0; i < n; i++) {
    if (b[s[i] - 'a'])
      count++;
    else {
      length.push_back(count);
      count = 0;
    }
    if (i == n - 1) length.push_back(count);
  }
  long long sum = 0;
  for (int i = 0; i < length.size(); i++)
    sum += (length[i] * (length[i] + 1)) / 2;
  cout << sum;
}
