#include <bits/stdc++.h>
using llong = long long;
int check_drop(int j, const std::vector<char> &t, const std::vector<char> &d,
               const int Q, const int N, const std::string &s) {
  assert(1 <= j and j <= N);
  for (int i = 1; i <= Q; ++i) {
    if (t[i] == s[j]) {
      if (d[i] == 'L') {
        if (j == 1) {
          return -1;
        } else {
          j -= 1;
        }
      } else if (d[i] == 'R') {
        if (j == N) {
          return 1;
        } else {
          j += 1;
        }
      }
    }
  }
  return 0;
}
int main() {
  int N;
  int Q;
  std::cin >> N >> Q;
  assert(1 <= N and N <= 2 * 1.0e+5);
  assert(1 <= Q and Q <= 2 * 1.0e+5);
  std::string s;
  std::cin >> s;
  s.insert(s.begin(), '-');
  assert(static_cast<int>(s.length()) == 1 + N);
  std::vector<char> t(1 + Q);
  std::vector<char> d(1 + Q);
  for (int i = 1; i <= Q; ++i) {
    std::cin >> t[i] >> d[i];
    assert(d[i] == 'L' or d[i] == 'R');
  }
  int lMax = N;
  if (check_drop(lMax, t, d, Q, N, s) == -1) {
    std::cout << 0 << std::endl;
  }
  int lMin = 1;
  if (check_drop(lMin, t, d, Q, N, s) == -1) {
    assert(lMin <= lMax);
    int lCurrent = (lMax + lMin) / 2;
    while (lMin < lCurrent and lCurrent < lMax) {
      assert(lMin <= lMax);
      int m = check_drop(lCurrent, t, d, Q, N, s);
      if (m == -1) {
        lMin = lCurrent;
      } else {
        lMax = lCurrent;
      }
      lCurrent = lMin + (lMax - lMin) / 2;
    }
  } else {
    lMin = 0;
    lMax = 1;
  }
  int rMin = 1;
  if (check_drop(rMin, t, d, Q, N, s) == 1) {
    std::cout << 0 << std::endl;
  }
  int rMax = N;
  if (check_drop(rMax, t, d, Q, N, s) == 1) {
    assert(rMin <= rMax);
    int rCurrent = (rMax + rMin) / 2;
    while (rMin < rCurrent and rCurrent < rMax) {
      assert(rMin <= rMax);
      int m = check_drop(rCurrent, t, d, Q, N, s);
      if (m == 1) {
        rMax = rCurrent;
      } else {
        rMin = rCurrent;
      }
      rCurrent = rMin + (rMax - rMin) / 2;
    }
  } else {
    rMax = N + 1;
    rMin = N;
  }
  std::cout << rMin - lMax + 1 << std::endl;
  return 0;
}
