#include <bits/stdc++.h>
using namespace std;
using vint = vector<long long>;
using vvint = vector<vint>;
using pint = pair<long long, long long>;
using vpint = vector<pint>;
template <typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double pi = 3.1415926535897932384626433832795028;
constexpr long long dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr long long dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
long long gcd(long long a, long long b) {
  while (b) {
    swap(a %= b, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
  os << "(" << rhs.first << ", " << rhs.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &rhs) {
  os << "{";
  for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
    os << *itr << (next(itr) != rhs.end() ? ", " : "");
  }
  os << "}";
  return os;
}
struct Setup {
  static constexpr long long PREC = 20;
  Setup() {
    cout << fixed << setprecision(PREC);
    cerr << fixed << setprecision(PREC);
  };
} setup;
long long binarySearch(long long ok, long long ng,
                       std::function<bool(long long)> check) {
  while (abs(ok - ng) > 1) {
    long long mid = (ok + ng) / 2;
    (check(mid) ? ok : ng) = mid;
  }
  return ok;
}
long long N, Q;
string s;
char t[220000], d[220000];
signed main() {
  cin >> N >> Q;
  cin >> s;
  for (long long i = 0; i < (Q); i++) {
    cin >> t[i] >> d[i];
  }
  long long l = binarySearch(-1, N - 1, [&](long long x) {
    long long cur = x;
    for (long long i = 0; i < (Q); i++) {
      if (t[i] == s[cur]) {
        if (d[i] == 'L') {
          cur--;
        }
        if (d[i] == 'R') {
          cur++;
        }
      }
      if (cur == -1) {
        return true;
      }
      if (cur == N) {
        return false;
      }
    }
    return false;
  });
  long long r = binarySearch(N, 0, [&](long long x) {
    long long cur = x;
    for (long long i = 0; i < (Q); i++) {
      if (t[i] == s[cur]) {
        if (d[i] == 'L') {
          cur--;
        }
        if (d[i] == 'R') {
          cur++;
        }
      }
      if (cur == -1) {
        return false;
      }
      if (cur == N) {
        return true;
      }
    }
    return false;
  });
  cout << N - (l + 1) - (N - r) << endl;
}
