#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    set<char> m;
    for (int i = 1; i <= k; i++) {
      char c;
      cin >> c;
      m.insert(c);
    }
    bool f[n];
    memset(f, 1, sizeof(f));
    for (int i = 0; i < n; i++) {
      if (m.find(s[i]) == m.end()) f[i] = 0;
    }
    vector<long long> v;
    long long cur = 0;
    for (int i = 0; i < n; i++) {
      if (f[i])
        cur++;
      else {
        v.push_back(cur * (cur + 1) / 2);
        cur = 0;
      }
    }
    v.push_back(cur * (cur + 1) / 2);
    long long a = 0;
    for (auto x : v) a += x;
    cout << a << "\n";
  }
  return 0;
}
