#include <bits/stdc++.h>
using namespace std;
using ll = long long;
namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
}  // namespace NS
ll N, Q;
string s;
vector<pair<char, char>> command;
int main() {
  cin >> N >> Q;
  cin >> s;
  command.resize(Q);
  for (ll i = 0; i < Q; ++i) {
    cin >> command[i].first >> command[i].second;
  }
  ll leftPos = -1;
  ll rightPos = N;
  ll ans;
  for (ll i = Q - 1; i >= 0; --i) {
    if (leftPos < N - 1) {
      if (leftPos == -1 or leftPos == 0) {
        if (s[leftPos + 1] == command[i].first and command[i].second == 'L') {
          ++leftPos;
        }
      } else if (leftPos >= 1) {
        if (s[leftPos + 1] == command[i].first) {
          if (command[i].second == 'L') {
            ++leftPos;
          }
        }
      }
    } else {
      ans = 0;
      cout << ans << endl;
      return 0;
    }
    if (rightPos > 0) {
      if (rightPos == N or rightPos == N - 1) {
        if (s[rightPos - 1] == command[i].first and command[i].second == 'R') {
          --rightPos;
        }
      } else if (rightPos < N - 1) {
        if (s[rightPos - 1] == command[i].first and command[i].second == 'R') {
          --rightPos;
        }
      }
    } else {
      ans = 0;
      cout << ans << endl;
      return 0;
    }
  }
  if (leftPos >= rightPos) {
    ans = 0;
  } else {
    ans = rightPos - leftPos - 1;
  }
  cout << ans << endl;
}
