#include <bits/stdc++.h>
using namespace std;
char str[1000005], leave[300];
int flag[1000005], a, b;
int main() {
  scanf("%d%d", &a, &b);
  getchar();
  for (int i = 0; i < a; i++) {
    scanf("%c", &str[i]);
  }
  getchar();
  for (int i = 0; i < b; i++) {
    scanf("%c", &leave[i]);
    getchar();
    for (int j = 0; j < a; j++) {
      if (leave[i] == str[j]) {
        flag[j] = 1;
      }
    }
  }
  long long num = 0, sum = 0;
  for (int i = 0; i < a; i++) {
    if (flag[i] == 1) {
      sum++;
    }
    if (flag[i] != 1 || i == a - 1) {
      num = num + sum * (sum + 1) / 2;
      sum = 0;
    }
  }
  printf("%lld\n", num);
  return 0;
}
