#include <bits/stdc++.h>
using namespace std;
unsigned long long solve(int n, int k, string s, string c) {
  unsigned long long result = 0;
  for (int j = 0; j < s.length(); j++) {
    bool found = false;
    for (int i = 0; i < c.length(); i++) {
      if (s[j] == c[i]) {
        found = true;
      }
    }
    if (!found) {
      s[j] = ' ';
    }
  }
  unsigned long long length = 0;
  unsigned long long last = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == ' ') {
      result += length * (length + 1) / 2;
      length = 0;
      last = i + 1;
    } else {
      length++;
    }
  }
  unsigned long long remaining = s.length() - last;
  result += remaining * (remaining + 1) / 2;
  return result;
}
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string c = "";
  for (int i = 0; i < k; i++) {
    char x;
    cin >> x;
    c += x;
  }
  cout << solve(n, k, s, c) << endl;
  return 0;
}
