#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string c;
  char cc;
  for (int i = 0; i < k; i++) {
    cin >> cc;
    c.push_back(cc);
  }
  long long ans = 0, p;
  int flag = 0, count = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    flag = 0;
    for (int j = 0; j < c.size(); j++) {
      if (s[i] == c[j]) flag = 1;
    }
    {
      if (flag == 0) {
        p = i - count;
        ans += ((p * (p + 1)) / 2);
        count = i + 1;
      }
    }
  }
  p = n - count;
  ans += ((p * (p + 1)) / 2);
  cout << (ans);
  return 0;
}
