#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  map<char, bool> ma;
  char h;
  long long n, m, a = 0, ans = 0;
  string s;
  cin >> n >> m >> s;
  for (int i = 0; i < m; i++) {
    cin >> h;
    ma[h] = 1;
  }
  for (int i = 0; i < s.size(); i++) {
    if (ma[s[i]]) {
      a++;
    } else if (ma[s[i - 1]]) {
      v.push_back(a);
      a = 0;
    }
  }
  if (ma[s[s.size() - 1]]) {
    v.push_back(a);
    a = 0;
  }
  for (int i = 0; i < v.size(); i++) {
    long long b = 0;
    for (int j = 1; j <= v[i]; j++) {
      b += j;
    }
    ans += b;
  }
  cout << ans;
}
