#include <bits/stdc++.h>   using namespace std;   const int INF = 100005;   const long long LL_INF = (long long)2e18 + 5;   inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   const long long mod = 1000000007;   bool isprime(long long n) {     for (long long i = 2; i * i <= n; ++i) {       if (n % i == 0) {         return false;       }     }     return true;   }   long long factorial(long long n) {     return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);   }   long long power(long long x, long long y) {     long long res = 1;     x = x % mod;     while (y > 0) {       if (y & 1) res = ((res % mod) * (x % mod)) % mod;       y = y >> 1;       x = ((x % mod) * (x % mod)) % mod;     }     return res;   }   long long ncr(long long n, long long r) {     long long res = 1;     if (r > n) return 0;     if (r > n - r) r = n - r;     for (long long i = 0; i < r; i++) {       res = ((res % mod) * ((n - i) % mod)) % mod;       res = ((res % mod) * (power(i + 1, mod - 2)) % mod) % mod;     }     return res;   }   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }   long long max(long long a, long long b) {     long long sol = a > b ? a : b;     return sol;   }   long long min(long long a, long long b) {     long long sol = a < b ? a : b;     return sol;   }   map<long long, long long> mp;   inline void solve() {     long long n, k;     long long a[26] = {0};     cin >> n >> k;     string s;     cin >> s;     char ch;     while (k--) {       cin >> ch;       a[ch -  a ]++;     }     long long prev = -1, r;     long long ans = 0;     for (int i = 0; i < n; i++) {       if (a[s[i] -  a ] == 0) {         r = i - prev - 1;         ans += ((r * (r + 1)) / 2);         prev = i;       }     }     r = n - prev - 1;     ans += ((r * (r + 1)) / 2);     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     solve();   }   