#include <bits/stdc++.h>
using namespace std;
void file_IO() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  file_IO();
  long long t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    set<char> st;
    for (long long i = 0; i < k; i++) {
      char x;
      cin >> x;
      st.insert(x);
    }
    long long ct = 0;
    vector<long long> v;
    long long res = 0;
    for (char c : s) {
      if (st.find(c) != st.end())
        ct++;
      else {
        res += (ct * (ct + 1)) / 2;
        ct = 0;
      }
    }
    res += (ct * (ct + 1)) / 2;
    cout << res << "\n";
  }
  return 0;
}
