#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1),
                          make_pair(0, -1)};
constexpr char BR = '\n';
template <class T>
inline int argmin(vector<T> vec) {
  return min_element(vec.begin(), vec.end()) - vec.begin();
}
template <class T>
inline int argmax(vector<T> vec) {
  return max_element(vec.begin(), vec.end()) - vec.begin();
}
template <class T>
inline void chmax(T &a, T b) {
  a = max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = min(a, b);
}
inline int toInt(string &s) {
  int res = 0;
  for (char a : s) res = 10 * res + (a - '0');
  return res;
}
inline int toInt(const string s) {
  int res = 0;
  for (char a : s) res = 10 * res + (a - '0');
  return res;
}
inline long long int toLong(string &s) {
  lli res = 0;
  for (char a : s) res = 10 * res + (a - '0');
  return res;
}
inline long long int toLong(const string s) {
  lli res = 0;
  for (char a : s) res = 10 * res + (a - '0');
  return res;
}
template <class T>
inline std::string toString(T n) {
  if (n == 0) return "0";
  std::string res = "";
  if (n < 0) {
    n = -n;
    while (n != 0) {
      res += (char)(n % 10 + '0');
      n /= 10;
    }
    std::reverse(res.begin(), res.end());
    return '-' + res;
  }
  while (n != 0) {
    res += (char)(n % 10 + '0');
    n /= 10;
  }
  std::reverse(res.begin(), res.end());
  return res;
}
inline int AtoInt(char a) { return (int)(a - 'A'); }
constexpr int num_alpha = 26;
int n, q;
string s;
int main(void) {
  cin >> n >> q;
  cin >> s;
  using TMP = pair<char, int>;
  using DATA = vector<TMP>;
  DATA Qs(q);
  for (int(i) = (0); (i) < (q); (i)++) {
    char a, b;
    cin >> a >> b;
    int acc = ((b == 'L') ? -1 : 1);
    Qs.at(i) = make_pair(a, acc);
  }
  set<int> koho{-1, n};
  for (auto P = Qs.end(); P != Qs.begin() - 1; P--) {
    char a = P->first;
    int acc = P->second;
    queue<int> next_tuika;
    for (auto &(pos) : (koho)) {
      int thinking_position = pos - acc;
      if (0 <= thinking_position and thinking_position < n) {
        if (s.at(thinking_position) == a) {
          next_tuika.push(thinking_position);
        }
      }
    }
    while (not next_tuika.empty()) {
      koho.insert(next_tuika.front());
      next_tuika.pop();
    }
  }
  int disapp = koho.size() - 2;
  cout << n - disapp << BR;
  return 0;
}
