#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<pair<char, char>> F;
  for (int x = 0; x < (Q); x++) {
    char t, d;
    cin >> t >> d;
    F.push_back(make_pair(t, d));
  }
  int ans = 0;
  int left = 0;
  int right = N;
  int j = 0;
  while (j++ <= 20) {
    int check = (left + right) / 2;
    char place = S.at(check);
    bool fail = false;
    for (int x = 0; x < (Q); x++) {
      if (F.at(x).first == place) {
        if (F.at(x).second == 'R') {
          check++;
          if (check < N) {
            place = S.at(check);
          } else {
            fail = true;
            break;
          }
        } else {
          check--;
          if (check >= 0) {
            place = S.at(check);
          } else {
            fail = true;
            break;
          }
        }
      }
    }
    if (fail) {
      right = (left + right) / 2;
    } else {
      left = (left + right) / 2;
    }
    ans = (left + right) / 2;
  }
  int res = 0;
  left = 0;
  right = N;
  int i = 0;
  while (i++ <= 20) {
    int check = (left + right) / 2;
    char place = S.at(check);
    bool fail = false;
    for (int x = 0; x < (Q); x++) {
      if (F.at(x).first == place) {
        if (F.at(x).second == 'R') {
          check++;
          if (check < N) {
            place = S.at(check);
          } else {
            fail = true;
            break;
          }
        } else {
          check--;
          if (check >= 0) {
            place = S.at(check);
          } else {
            fail = true;
            break;
          }
        }
      }
    }
    if (fail) {
      left = (left + right) / 2;
    } else {
      right = (left + right) / 2;
    }
    res = (left + right) / 2;
  }
  cout << ans - res << endl;
}
