#include <bits/stdc++.h>
using namespace std;
map<char, int> mp;
char c;
int main() {
  long long n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  long long ans = 0, sum = 1;
  for (int i = 1; i <= m; ++i) {
    cin >> c;
    mp[c]++;
  }
  for (int i = 0; i < s.size(); ++i) {
    if (mp[s[i]]) {
      ans += sum;
      sum++;
    } else {
      sum = 1;
    }
  }
  cout << ans;
  return 0;
}
