#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
int extincted[200000];
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<pair<char, char> > queries(q);
  char t, d;
  for (int i = 0; i < q; ++i) {
    cin >> queries[i].second >> queries[i].first;
  }
  int l = 0, r = 0, l_max = 0, r_min = 0;
  for (int i = q - 1; i >= 0; --i) {
    if (queries[i].first == 'L' && queries[i].second == s[l % n]) {
      ++l;
      l_max = max(l, l_max);
    } else if (queries[i].first == 'R' &&
               queries[i].second == s[(r - 1 + n) % n]) {
      --r;
      r_min = min(r, r_min);
    }
  }
  cout << n - l_max + r_min << endl;
}
