#include <bits/stdc++.h>
namespace {
using namespace std;
template <typename T>
inline bool whitespace(const vector<T> &) {
  return false;
}
template <typename T>
inline bool whitespace(const T &) {
  return true;
}
inline bool whitespace(const char) { return false; }
template <typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
  os << p.first << (whitespace(p.second) ? " " : "") << p.second << '\n';
  return os;
}
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &t : v) {
    os << t + 1 << (whitespace(t) ? " " : "");
  }
  os << '\n';
  return os;
}
template <typename T>
T gcd(T a, T b) {
  while (b) {
    T mod = a % b;
    a = b;
    b = mod;
  }
  return a;
}
template <typename C>
void incr_sort(C &v) {
  stable_sort(v.begin(), v.end());
}
template <typename C>
void decr_sort(C &v) {
  stable_sort(v.rbegin(), v.rend());
}
template <typename T>
T sum(const vector<T> &v) {
  T s = 0;
  for (T value : v) s += value;
  return s;
}
template <typename T>
vector<T> prefix_sum(const vector<T> &v) {
  vector<T> res(v.size());
  res[0] = v[0];
  for (long long i = 1; i < v.size(); ++i) res[i] = res[i - 1] + v[i];
  return res;
}
class ExitException : exception {};
template <typename T>
void answer(T ans, ostream &os = cout) {
  os << ans << "\n";
  throw ExitException();
}
const char *to_string(const vector<long long> &v) {
  ostringstream ss;
  for (const auto &item : v) ss << item << (whitespace(item) ? " " : "");
  return ss.str().c_str();
}
const char *to_string(const vector<vector<long long>> &v) {
  string *s = new string;
  for (const auto &item : v) *s += string(to_string(item)) + "   ";
  return s->c_str();
}
const char *to_string(const pair<long long, long long> &p) {
  ostringstream ss;
  ss << p.first << ", " << p.second;
  return ss.str().c_str();
}
const char *to_string(const map<long long, long long> &m) {
  ostringstream ss;
  for (const auto &item : m) ss << "(" << item << ") ";
  return ss.str().c_str();
}
const char *to_string(const set<long long> &s) {
  ostringstream ss;
  for (const auto &item : s) ss << "(" << item << ") ";
  return ss.str().c_str();
}
}  // namespace
void solve();
signed main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  long long t = 1;
  do {
    try {
      solve();
    } catch (ExitException) {
    }
  } while (--t);
  return 0;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  set<char> letters;
  for (long long i = 0; i < k; ++i) {
    char c;
    cin >> c;
    letters.insert(c);
  }
  vector<bool> good(n);
  for (long long i = 0; i < n; ++i) {
    good[i] = letters.find(s[i]) != letters.end();
  }
  long long len = 0;
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    if (good[i])
      ++len;
    else {
      ans += len * (len + 1) / 2;
      len = 0;
    }
  }
  answer(ans + len * (len + 1) / 2);
}
