#include <bits/stdc++.h>
using namespace std;
char c[30], vis[30];
pair<int, int> p[200000 + 100];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < k; i++) {
    cin >> c[i];
    vis[c[i] - 'a'] = 1;
  }
  int len = s.length();
  int ss, tt;
  ss = -1;
  int cnt = 0;
  for (int i = 0; i < len; i++) {
    if (ss == -1) {
      if (vis[s[i] - 'a']) {
        ss = tt = i;
      }
    } else {
      if (vis[s[i] - 'a'] && vis[s[i - 1] - 'a']) {
        tt++;
      } else {
        p[cnt++] = {ss, tt};
        while (!vis[s[i] - 'a']) i++;
        ss = tt = i;
      }
    }
  }
  if (vis[s[len - 1] - 'a']) p[cnt++] = {ss, tt};
  unsigned long long ans = 0;
  for (int i = 0; i < cnt; i++) {
    int ln = p[i].second - p[i].first + 1;
    ans += ((unsigned long long)(ln) * (unsigned long long)(ln + 1)) / 2;
  }
  cout << ans << endl;
}
