#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
void chmax(string& a, string b) {
  if (a == "-")
    a = b;
  else if (a.size() < b.size())
    a = b;
  else if (a.size() == b.size()) {
    if (a < b) a = b;
  }
}
template <typename T>
inline T intceil(T a, T b) {
  return (a + (b - 1)) / b;
}
const long long MOD = 1e9 + 7;
const long long INFLL = (1LL << 62) - 1;
const int INFI = (1 << 30) - 1;
template <typename T>
void printv(vector<T>& v) {
  int n = v.size() - 1;
  for (int i = 0; i < n; ++i) cout << v[i] << " ";
  cout << v.back() << endl;
}
static const long double pi = acos(-1.0);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = {0, 1, 0, -1};
const int dx[4] = {1, 0, -1, 0};
int N, Q;
string S;
vector<char> T, D;
int check(int pos) {
  for (int i = 0; i < Q; ++i) {
    if (T[i] == S[pos]) {
      pos += D[i] == 'R' ? 1 : -1;
      if (pos == -1)
        return 1;
      else if (pos == N)
        return 2;
    }
  }
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> Q;
  cin >> S;
  T.resize(Q);
  D.resize(Q);
  for (int i = 0; i < Q; ++i) cin >> T[i] >> D[i];
  int ans = 0;
  if (check(0) == 1) {
    int ok = 0, ng = N - 1;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      if (check(mid) == 1) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cerr << "["
         << "ok"
         << "]:",
        debug_out(ok);
    ans += (ok + 1);
  }
  if (check(N - 1) == 2) {
    int ok = N - 1, ng = 0;
    while (ok - ng > 1) {
      int mid = (ok + ng) / 2;
      if (check(mid) == 2) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cerr << "["
         << "ok"
         << "]:",
        debug_out(ok);
    ans += (N - 1) - ok + 1;
  }
  cout << N - ans << endl;
  ;
}
