#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  unordered_set<char> set;
  char c;
  while (k--) {
    cin >> c;
    set.insert(c);
  }
  ll answer = 0;
  ll curr = 0;
  for (int i = 0; i < s.length(); i++) {
    if (set.find(s[i]) != set.end()) {
      curr++;
    } else {
      answer += (curr * (curr + 1) / 2);
      curr = 0;
    }
  }
  answer += (curr * (curr + 1) / 2);
  cout << answer;
}
