#include <bits/stdc++.h>
using namespace std;
long long n, k, sz, l = 1, r, ans, x = 0, rig;
char let;
string h;
map<char, long long> mp;
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> k;
  cin >> h;
  h = "z" + h;
  for (long long i = 1; i <= k; i++) {
    cin >> let;
    mp[let] = 1;
  }
  for (long long i = 1; i < h.size(); i++) {
    if (mp[h[i]] == 0) {
      if (mp[h[l]] == 0) {
        ans += ((i - l - 1) * (i - l)) / 2;
      } else if (mp[h[l]]) {
        ans += ((i - l) * (i - l + 1)) / 2;
      }
      l = i;
    } else if (mp[h[i]]) {
      if (i == h.size() - 1) {
        if (mp[h[l]] == 0) {
          ans += ((i - l) * (i - l + 1)) / 2;
        } else if (mp[h[l]]) {
          ans += ((i - l + 1) * (i - l + 2)) / 2;
        }
      }
    }
  }
  cout << ans;
}
