#include <bits/stdc++.h>
using namespace std;
int n, k;
long long ans = 0;
string s;
set<int> well;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> s;
  for (int i = 0; i < k; i++) {
    char x;
    cin >> x;
    well.insert(x);
  }
  int cur_seq = 0;
  for (int i = 0; i < n; i++) {
    if (well.count(s[i]))
      cur_seq++;
    else {
      ans += 1ll * cur_seq * (cur_seq + 1) / 2;
      cur_seq = 0;
    }
  }
  ans += 1ll * cur_seq * (cur_seq + 1) / 2;
  cout << ans << '\n';
}
