#include <bits/stdc++.h>
using namespace std;
const int next_x[8] = {0, 1, -1, 0, 1, 1, -1, -1};
const int next_y[8] = {1, 0, 0, -1, 1, -1, -1, 1};
const int inf = 2147483647;
const long long linf = 1e18 + 5;
const double PI = acos(-1.0);
const long double eps = 1e-12;
const int MAXN = 1e6 + 5;
const int N = 1e6;
const int fix = 1e5;
long long M = 1e9 + 7;
const int K = 30;
int n, m;
char s[MAXN];
bool v[26];
int f[MAXN];
int work() {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  for (register int i = (1), I = (m) + 1; i < I; ++i) {
    char t[10];
    scanf("%s", t);
    v[t[0] - 'a'] = 1;
  }
  for (register int i = (1), I = (n) + 1; i < I; ++i) f[i] = v[s[i] - 'a'];
  f[n + 1] = 0;
  long long ans = 0;
  for (register int i = (2), I = (n + 1) + 1; i < I; ++i) {
    if (f[i])
      f[i] += f[i - 1];
    else if (f[i - 1])
      ans += (long long)f[i - 1] * (f[i - 1] - 1) / 2 + f[i - 1];
  }
  return printf("%lld\n", ans);
}
int main() {
  work();
  return 0;
}
