#include <bits/stdc++.h>
using namespace std;
int N, Q;
string s;
vector<char> t;
vector<char> d;
tuple<char, int> calc(int target) {
  int index = target;
  for (int i = 0; i < Q; i++) {
    char c = s[index];
    if (t[i] == c) {
      if (d[i] == 'L') {
        index--;
      } else {
        index++;
      }
      if (index == -1) {
        return forward_as_tuple('L', target);
      } else if (index == N) {
        return forward_as_tuple('R', target);
      }
    }
  }
  if (target > 0) {
    return calc(target - 1);
  } else if (target < N) {
    return calc(target + 1);
  }
  return forward_as_tuple('C', -1);
}
int main() {
  cin >> N >> Q;
  cin >> s;
  for (int i = 0; i < Q; i++) {
    char tt, dd;
    cin >> tt >> dd;
    t.push_back(tt);
    d.push_back(dd);
  }
  int target = N / 2;
  char c;
  int i;
  tie(c, i) = calc(target);
  if (c == 'C') {
    cout << N << endl;
  } else if (c == 'L') {
    char cc;
    int ii;
    while (true) {
      tie(cc, ii) = calc(target + 1);
      if (cc != 'L') {
        break;
      }
    }
    if (cc == 'R') {
      cout << ii - i - 1 << endl;
    } else {
      cout << N - i - 1 << endl;
    }
  } else {
    char cc;
    int ii;
    while (true) {
      tie(cc, ii) = calc(target - 1);
      if (cc != 'R') {
        break;
      }
    }
    if (cc == 'L') {
      cout << i - ii - 1 << endl;
    } else {
      cout << i << endl;
    }
  }
  return 0;
}
