#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int tt;
  tt = 1;
  while (tt--) {
    long long int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<char> a(k);
    for (long long int i = 0; i < k; i++) cin >> a[i];
    long long int x = 0;
    long long int count = 0;
    long long int ans = 0;
    for (long long int i = 0; i < n; i++) {
      x = 0;
      for (long long int j = 0; j < k; j++) {
        if (s[i] == a[j]) {
          x = 1;
          count++;
          break;
        }
      }
      if (x == 0 || i == n - 1) {
        ans += (count * (count + 1) / 2);
        count = 0;
        continue;
      }
    }
    cout << ans << endl;
  }
}
