#include <bits/stdc++.h>
using namespace std;
const int INF = 200005;
const long long LINF = 1001001001001001001;
const int MOD = 1e9 + 7;
int N = 0;
int Q = 0;
string str;
char cell[INF];
int ret = 0;
vector<char> t;
vector<char> d;
map<int, map<int, int>> DP;
int getTable(int n, int q) {
  auto itr = DP.find(n);
  if (itr == DP.end()) {
    return -1;
  } else {
    map<int, int> temp = DP[n];
    auto itr2 = temp.find(q);
    if (itr2 == temp.end()) {
      return -1;
    } else {
      return temp[q];
    }
  }
}
void setTable(int n, int q, int value) { DP[n][q] = value; }
int canStay(int n, int q) {
  if (getTable(n, q) != -1) {
    return getTable(n, q);
  } else if (q == Q) {
    return 1;
  } else {
    int now = n;
    if (t[q + 1] == cell[n]) {
      if (d[q + 1] == 'L') {
        now--;
      } else if (d[q + 1] == 'R') {
        now++;
      } else {
        cerr << ("WRONG") << " ";
      }
      if (now == 0 || now == N + 1) {
        setTable(n, q, 0);
        return 0;
      } else {
        int ans = canStay(now, q + 1);
        setTable(n, q, ans);
        return ans;
      }
    } else {
      int ans = canStay(n, q + 1);
      setTable(n, q, ans);
      return ans;
    }
  }
}
void input() {
  cin >> N;
  cin >> Q;
  cin >> str;
  for (int i = 0; i < (N); i++) {
    cell[i + 1] = str[i];
  }
  t.push_back('b');
  d.push_back('b');
  for (int i = 0; i < (Q); i++) {
    char c;
    char dir;
    cin >> c;
    cin >> dir;
    t.push_back(c);
    d.push_back(dir);
  }
}
void solve() {
  for (int i = 0; i < (N); i++) {
    int ans = canStay(i + 1, 0);
    if (ans == 1) {
      ret++;
    }
  }
}
int main(void) {
  input();
  solve();
  cout << (ret) << endl;
}
