#include <bits/stdc++.h>
using namespace std;
const int INF = (0x7FFFFFFFL);
const long long INFF = (0x7FFFFFFFFFFFFFFFL);
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MOD = 1e9 + 7;
const int MODD = 998244353;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1.0);
const double EPS = 1e-9;
const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[9] = {0, 1, 0, -1, -1, -1, 1, 1, 0};
template <typename T>
void MACRO_VAR_Scan(T &t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &...rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &j) {
  o << "{" << j.first << ", " << j.second << "}";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &j) {
  o << "{";
  for (int i = 0; i < (int)j.size(); ++i) o << (i > 0 ? ", " : "") << j[i];
  o << "}";
  return o;
}
inline int print(void) {
  cout << endl;
  return 0;
}
template <class Head>
int print(Head &&head) {
  cout << head;
  print();
  return 0;
}
template <class Head, class... Tail>
int print(Head &&head, Tail &&...tail) {
  cout << head << " ";
  print(forward<Tail>(tail)...);
  return 0;
}
inline int debug(void) {
  cerr << endl;
  return 0;
}
template <class Head>
int debug(Head &&head) {
  cerr << head;
  debug();
  return 0;
}
template <class Head, class... Tail>
int debug(Head &&head, Tail &&...tail) {
  cerr << head << " ";
  debug(forward<Tail>(tail)...);
  return 0;
}
template <typename T>
void PA(T &a) {
  int ASIZE = sizeof(a) / sizeof(a[0]);
  for (int ii = 0; ii < ASIZE; ++ii) {
    cout << a[ii] << " \n"[ii == ASIZE - 1];
  }
}
template <typename T>
void PV(T &v) {
  int VSIZE = v.size();
  for (int ii = 0; ii < VSIZE; ++ii) {
    cout << v[ii] << " \n"[ii == VSIZE - 1];
  }
}
inline int YES(bool x) {
  cout << ((x) ? "YES" : "NO") << endl;
  return 0;
}
inline int Yes(bool x) {
  cout << ((x) ? "Yes" : "No") << endl;
  return 0;
}
inline int yes(bool x) {
  cout << ((x) ? "yes" : "no") << endl;
  return 0;
}
inline int yES(bool x) {
  cout << ((x) ? "yES" : "nO") << endl;
  return 0;
}
inline int Yay(bool x) {
  cout << ((x) ? "Yay!" : ":(") << endl;
  return 0;
}
template <typename A, typename B>
void sankou(bool x, A a, B b) {
  cout << ((x) ? (a) : (b)) << endl;
}
inline long long MOP(long long x, long long n, long long m = MOD) {
  long long r = 1;
  while (n > 0) {
    if (n & 1) (r *= x) %= m;
    (x *= x) %= m;
    n >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long POW(long long a, long long b) {
  long long c = 1ll;
  do {
    if (b & 1) c *= 1ll * a;
    a *= 1ll * a;
  } while (b >>= 1);
  return c;
}
template <typename T, typename A, typename B>
inline bool between(T x, A a, B b) {
  return ((a <= x) && (x < b));
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename A, typename B>
inline bool chmax(A &a, const B &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, typename B>
inline bool chmin(A &a, const B &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct abracadabra {
  abracadabra() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(5);
  };
} ABRACADABRA;
signed main() {
  int N, Q;
  MACRO_VAR_Scan(N, Q);
  ;
  string S;
  MACRO_VAR_Scan(S);
  ;
  vector<pair<string, string>> query;
  for (long long i = long long(0); i < long long(Q); ++i) {
    string t, d;
    MACRO_VAR_Scan(t, d);
    ;
    query.push_back(make_pair(t, d));
  }
  function<bool(long long)> check = [&](long long mid) {
    for (auto &q : query) {
      string t, d;
      tie(t, d) = q;
      if (S[mid] == t[0]) {
        if (d[0] == 'L')
          --mid;
        else
          ++mid;
      }
      if (mid < 0 or mid >= N) {
        return true;
      }
    }
    return false;
  };
  int l;
  {
    long long ok = -1, ng = N;
    while (abs(ok - ng) > 1) {
      long long mid = (ok + ng) / 2;
      if (check(mid)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    l = ok;
  }
  int r;
  {
    long long ok = N, ng = -1;
    while (abs(ok - ng) > 1) {
      long long mid = (ok + ng) / 2;
      if (check(mid)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    r = ok;
  }
  print(r - 1 - l);
}
