#include <bits/stdc++.h>
using namespace std;
long long n, k, i, j, ans;
set<char> a;
string s;
char x;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> s;
  vector<long long> dp(n, 1);
  for (i = 0; i < k; i++) {
    cin >> x;
    a.insert(x);
  }
  for (i = 0; i < n; i++)
    if (a.find(s[i]) != a.end())
      if (i - 1 >= 0)
        dp[i] = dp[i - 1] + 1;
      else
        ;
    else
      dp[i] = 0;
  for (i = n - 1; i >= 0;) {
    while (dp[i] == 0) i--;
    if (i >= 0) {
      ans += dp[i] * (dp[i] + 1) / 2;
      i -= dp[i];
    }
  }
  cout << ans;
  return 0;
}
