#include <bits/stdc++.h>
using namespace std;
template <class T>
void show(const vector<T> &a) {
  for (T x : a) cout << x << " ";
  cout << '\n';
}
const long long N = 3e5 + 100, oo = 1e18 + 9;
const long long mod = 1e9 + 9;
const long double eps = 1e-9, PI = 2 * acos(0.0);
long long n, m, k;
long long cnt = 0;
vector<long long> g[N];
vector<long long> visit(N, 0);
signed main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> k;
  string s;
  cin >> s;
  set<char> st;
  for (long long i = 0; i < k; i++) {
    char c;
    cin >> c;
    st.insert(c);
  }
  for (long long i = 0; i < n; i++) {
    long long j = i;
    while (j < n && st.count(s[j])) {
      j++;
    }
    long long tmp = j - i;
    i = j;
    cnt += tmp * (tmp + 1) / 2;
  }
  cout << cnt;
}
