#include <bits/stdc++.h>
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  return a * b / gcd(a, b);
}
template <typename T>
T clamp(T val, T min, T max) {
  return val < min ? min : (max < val ? max : val);
}
template <typename T>
size_t max_index(T begin, T end) {
  return distance(begin, max_element(begin, end));
}
template <typename T>
size_t min_index(T begin, T end) {
  return distance(begin, min_element(begin, end));
}
using namespace std;
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long num = 0;
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  string s;
  cin >> s;
  vector<long long> g(n, 1);
  map<char, vector<long long>> mem;
  for (long long i = 0; i < n; ++i) {
    mem[s[i]].push_back(i);
  }
  num = n;
  for (long long i = 0; i < q; ++i) {
    char t;
    cin >> t;
    char d;
    cin >> d;
    if (!mem.count(t)) continue;
    auto v = mem[t];
    for (auto it = v.begin(); it < v.end(); ++it) {
      if (d == 'L') {
        if (0 <= *it - 1) {
          g[*it - 1] += g[*it];
        } else {
          num -= g[*it];
        }
      } else {
        if (*it + 1 < n) {
          g[*it + 1] += g[*it];
        } else {
          num -= g[*it];
        }
      }
      g[*it] = 0;
    }
  }
  cout << num << endl;
  return 0;
}
