#include <bits/stdc++.h>
using namespace std;
const int maxn = 35;
int vis[maxn];
string s;
int n, k;
int main() {
  cin >> n >> k;
  cin >> s;
  for (int i = 1; i <= k; i++) {
    char tp;
    cin >> tp;
    vis[tp - 'a'] = 1;
  }
  long long ans = 0;
  s = " " + s;
  int p = 1;
  for (int i = 1; i <= n; i++) {
    int tp = s[i] - 'a';
    if (vis[tp] == 0) p = i + 1;
    ans += (i - p + 1);
  }
  cout << ans << endl;
}
