#include <bits/stdc++.h>
long long mod = 1e9 + 7;
class Mint {
 public:
  long long x;
  Mint(){};
  Mint(long long a) {
    x = a % mod;
    while (x < 0) {
      x += mod;
    }
  };
  Mint &operator+=(const Mint &a) {
    x += a.x;
    x %= mod;
    return *this;
  }
  Mint &operator-=(const Mint &a) {
    x += (mod - a.x);
    x %= mod;
    return *this;
  }
  Mint &operator*=(const Mint &a) {
    x *= a.x;
    x %= mod;
    return *this;
  }
  Mint pow(long long n) const {
    if (n == 0) return Mint(1);
    Mint y = pow(n >> 1);
    y *= y;
    if (n % 2 == 1) y *= *this;
    return y;
  }
  Mint modinv(const Mint &a) const { return a.pow(mod - 2); }
  Mint &operator/=(const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }
  Mint operator+(Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }
  Mint operator-(Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }
  Mint operator*(Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }
  Mint operator/(Mint &a) const {
    Mint y(*this);
    y /= a;
    return y.x;
  }
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x) < k; i.x++) {
      y *= (n - i);
      y /= (i + one);
    }
    return y;
  }
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x) < k; i.x++) {
      y *= (n - i);
    }
    return y;
  }
};
int main() {
  int N, Q;
  std::cin >> N >> Q;
  std::string s;
  std::cin >> s;
  std::vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    std::cin >> t[i] >> d[i];
  }
  int ng = 0;
  {
    int left = 0, right = N;
    while (right - left > 1) {
      int mid = (right + left) / 2;
      int pos = mid;
      int q = 0;
      while (q < Q && pos < N && pos >= 0) {
        if (t[q] == s[pos]) {
          if (d[q] == 'L')
            pos--;
          else
            pos++;
        }
        q++;
      }
      if (pos == N) {
        right = mid;
      } else {
        left = mid;
      }
    }
    ng += N - right;
  }
  {
    int left = -1, right = N - 1;
    while (right - left > 1) {
      int mid = (right + left) / 2;
      int pos = mid;
      int q = 0;
      while (q < Q && pos >= 0 && pos < N) {
        if (t[q] == s[pos]) {
          if (d[q] == 'L')
            pos--;
          else
            pos++;
        }
        q++;
      }
      if (pos == -1) {
        left = mid;
      } else {
        right = mid;
      }
    }
    ng += right;
  }
  std::cout << N - ng << std::endl;
  return 0;
}
