#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long a, b;
  cin >> a >> b;
  string x = "";
  cin >> x;
  set<char> s;
  for (int i = 0; i < b; i++) {
    char c;
    cin >> c;
    s.insert(c);
  }
  string aux = "";
  unsigned long long r = 0;
  for (int i = 0; i < x.size(); i++) {
    if (find(s.begin(), s.end(), x[i]) == s.end()) {
      long long t = aux.size();
      r += (t * (t + 1)) / 2;
      aux = "";
    } else {
      aux += x[i];
    }
  }
  long long t = aux.size();
  r += (t * (t + 1)) / 2;
  cout << r << endl;
}
