#include <bits/stdc++.h>
std::array<bool, 26> alphabet{};
int main() {
  int n, k;
  std::cin >> n >> k;
  std::string s;
  std::cin >> s;
  for (int i = 0; i < k; ++i) {
    char c;
    std::cin >> c;
    alphabet[c - 'a'] = true;
  }
  int start = 0;
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (i == n || !alphabet[s[i] - 'a']) {
      long long l = i - start;
      start = i + 1;
      ans += l * (l + 1) / 2;
    }
  }
  std::cout << ans;
}
