#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using pii = pair<long long, long long>;
const signed INF_ = 1001001001;
const long long INF = 1001001001001001001LL;
const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
                DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i) is >> *i;
  return is;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T, class U>
bool chmax(T &a, const U &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T, class U>
bool chmin(T &a, const U &b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
void PSUM(T &c) {
  partial_sum(begin(c), end(c), begin(c));
}
template <class T>
using heap = priority_queue<T, vector<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(15) << fixed;
  }
} before_main_function;
signed main() {
  long long N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<char, char>> td(Q);
  for (long long i = 0, ilen = (long long)(Q); i < ilen; ++i) {
    char t, d;
    cin >> t >> d;
    td[i] = {t, d};
  }
  long long left, right;
  {
    long long ok = N - 1;
    long long ng = -1;
    while (abs(ok - ng) > 1) {
      long long k = (ok + ng) / 2;
      bool removed = false;
      long long pos = k;
      for (long long i = 0, ilen = (long long)(Q); i < ilen; ++i) {
        char t, d;
        tie(t, d) = td[i];
        if (t == s[pos]) {
          if (d == 'L') {
            pos--;
          } else {
            pos++;
          }
        }
        if (pos < 0) {
          removed = true;
          break;
        }
      }
      if (removed) {
        ng = k;
      } else {
        ok = k;
      }
    }
    left = ok;
  }
  {
    long long ok = 0;
    long long ng = N;
    while (abs(ok - ng) > 1) {
      long long k = (ok + ng) / 2;
      bool removed = false;
      long long pos = k;
      for (long long i = 0, ilen = (long long)(Q); i < ilen; ++i) {
        char t, d;
        tie(t, d) = td[i];
        if (t == s[pos]) {
          if (d == 'L') {
            pos--;
          } else {
            pos++;
          }
        }
        if (pos >= N) {
          removed = true;
          break;
        }
      }
      if (removed) {
        ng = k;
      } else {
        ok = k;
      }
    }
    right = ok;
  };
  long long ans = right - left + 1;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return (0 ^ 0 ^ 0);
}
