#include <bits/stdc++.h>
using llong = long long;
llong checkDrop(llong j, const std::string &arrayChar,
                const std::vector<char> &queryChar,
                const std::vector<char> &queryDirection) {
  const llong numArray = arrayChar.length() - 1;
  const llong numQuery = queryChar.size() - 1;
  assert(numQuery == static_cast<llong>(queryDirection.size()) - 1);
  assert(1 <= j and j <= numArray);
  for (llong i = 1; i <= numQuery; ++i) {
    if (queryChar[i] == arrayChar[j]) {
      switch (queryDirection[i]) {
        case 'L':
          if (j == 1) return -1;
          --j;
          break;
        case 'R':
          if (j == numArray) return +1;
          ++j;
          break;
        default:
          assert(false);
      }
    }
  }
  return 0;
}
int main() {
  llong numArray;
  llong numQuery;
  std::cin >> numArray >> numQuery;
  assert(1 <= numArray and numArray <= 2 * 1.0e+5);
  assert(1 <= numQuery and numQuery <= 2 * 1.0e+5);
  std::string arrayChar;
  std::cin >> arrayChar;
  arrayChar.insert(arrayChar.begin(), '-');
  assert(static_cast<llong>(arrayChar.length()) == 1 + numArray);
  std::vector<char> queryChar(1 + numQuery);
  std::vector<char> queryDirection(1 + numQuery);
  for (llong i = 1; i <= numQuery; ++i) {
    std::cin >> queryChar[i] >> queryDirection[i];
    assert(queryDirection[i] == 'L' or queryDirection[i] == 'R');
  }
  llong lDrop = 0;
  llong lNotDrop = numArray + 1;
  llong lDropMax = lDrop + (lNotDrop - lDrop) / 2;
  while (lDrop < lDropMax) {
    assert(1 <= lDropMax and lDropMax <= numArray);
    assert(lDropMax < lNotDrop);
    llong m = checkDrop(lDropMax, arrayChar, queryChar, queryDirection);
    if (m == -1)
      lDrop = lDropMax;
    else
      lNotDrop = lDropMax;
    lDropMax = lDrop + (lNotDrop - lDrop) / 2;
  }
  assert(lDrop == lDropMax);
  llong rDrop = numArray + 1;
  llong rNotDrop = 0;
  llong rDropMin = rNotDrop + (rDrop - rNotDrop) / 2 + 1;
  while (rDropMin < rDrop) {
    assert(1 <= rDropMin and rDropMin <= numArray);
    assert(rNotDrop < rDropMin);
    llong m = checkDrop(rDropMin, arrayChar, queryChar, queryDirection);
    if (m == +1)
      rDrop = rDropMin;
    else
      rNotDrop = rDropMin;
    rDropMin = rNotDrop + (rDrop - rNotDrop) / 2 + 1;
  }
  assert(rDrop == rDropMin);
  std::cout << rDropMin - lDropMax - 1 << std::endl;
  return 0;
}
