#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  for (int j = 0; j < ((int)(v).size()); ++j) i >> v[j];
  return i;
}
template <typename T>
string join(const vector<T>& v) {
  stringstream s;
  for (int i = 0; i < ((int)(v).size()); ++i) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
inline ostream& operator<<(ostream& o, const vector<T>& v) {
  if ((int)(v).size()) o << join(v);
  return o;
}
template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}
template <typename T1, typename T2>
inline ostream& operator<<(ostream& o, const pair<T1, T2>& v) {
  return o << v.first << "," << v.second;
}
template <typename T>
inline long long int suma(const vector<T>& a) {
  long long int res(0);
  for (auto&& x : a) res += x;
  return res;
}
const double eps = 1e-10;
const long long int LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
int N, q;
string s;
pair<char, char> orders[200010];
int dfs(int index, int order) {
  if (order == q - 1) {
    return 1;
  }
  if (index == -1 || index == N) {
    return 0;
  }
  if (orders[order + 1].first == s[index + 1] &&
      orders[order + 1].second == 'L') {
    if (orders[order + 1].first == s[index]) {
      return dfs(index + 1, order + 1);
    }
    return dfs(index + 1, order + 1) + dfs(index, order + 1);
  } else if (orders[order + 1].first == s[index - 1] &&
             orders[order + 1].second == 'R') {
    if (orders[order + 1].first == s[index]) {
      return dfs(index + 1, order + 1);
    }
    return dfs(index - 1, order + 1) + dfs(index, order + 1);
  } else {
    if (orders[order + 1].first == s[index]) {
      return 0;
    }
    return dfs(index, order + 1);
  }
}
int main() {
  cin >> N >> q;
  cin >> s;
  for (int i = (q)-1; i >= 0; --i) {
    char str, dir;
    cin >> str >> dir;
    orders[i] = make_pair(str, dir);
  }
  int ans = 0;
  for (int i = 0; i < (q); ++i) {
    if (orders[i].first == s[0] && orders[i].second == 'L') {
      ans += dfs(0, i);
    }
    if (orders[i].first == s[N - 1] && orders[i].second == 'R') {
      ans += dfs(N - 1, i);
    }
  }
  cout << N - ans << endl;
  return 0;
}
