#include <bits/stdc++.h>
using namespace std;
struct Fast {
  Fast() {
    std::cin.tie(0);
    ios::sync_with_stdio(0);
  }
} fast;
template <class T>
bool chmax(T &a, const T &b) {
  return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  return (b < a) ? (a = b, 1) : 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
const long long inf = 1e9 + 7;
const long long dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const long long dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long long dxs[4] = {1, 0, -1, 0};
const long long dys[4] = {0, 1, 0, -1};
signed main(void) {
  long long n, q, sum = 0;
  char t, d;
  string s;
  cin >> n >> q >> s;
  vector<long long> v(n, 1);
  for (long long i = 0; i < q; i++) {
    cin >> t >> d;
    for (long long j = 0; j < n; j++) {
      if (s[j] == t) {
        if (((d == 'L') && (j == 0)) || ((d == 'R') && (j == (n - 1)))) {
          v.at(j) = 0;
        } else if ((d == 'L') && (v[j] > 0)) {
          v[j - 1] += v[j];
          v[j] = 0;
        } else if ((d == 'R') && (v[j] > 0)) {
          v[j + 1] += v[j];
          v[j] = 0;
        }
      }
    }
  }
  for (long long i = 0; i < (long long)(n); ++i) {
    sum += v[i];
  }
  cout << sum << endl;
  return 0;
}
