#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long infll = 1ll << 60ll;
const long long mod = 1e9 + 7;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<char> d(q);
  vector<char> t(q);
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  vector<bool> board(n, false);
  int left = 0;
  int right = n - 1;
  for (int i = q - 1; i >= 0; i--) {
    if (t[i] == s[left] && d[i] == 'L') {
      board[left] = true;
      left++;
    }
    if (t[i] == s[right] && d[i] == 'R') {
      board[right] = true;
      right--;
    }
  }
  vector<vector<pair<int, int>>> which(26, vector<pair<int, int>>());
  for (int i = 0; i < q; i++) {
    if (d[i] == 'L') {
      which[t[i] - 'A'].push_back({1, i});
    } else {
      which[t[i] - 'A'].push_back({2, i});
    }
  }
  long long ans = n;
  vector<int> map(n, 1);
  for (int i = 0; i < n; i++) {
    if (!board[i]) break;
    if (which[s[i] - 'A'][0].first == 1) {
      if (i == 0) {
        ans--;
        map[i] = 0;
      } else if (board[i - 1] == true) {
        ans -= map[i];
        map[i] = 0;
      }
    } else {
      if (i == n - 1) break;
      if (which[s[i + 1] - 'A'][0].first == 2 &&
          which[s[i] - 'A'][0].second > which[s[i + 1] - 'A'][0].second) {
        for (auto p : which[s[i + 1] - 'A']) {
          if (which[s[i] - 'A'][0].second < p.second && p.first == 2) break;
          if (which[s[i] - 'A'][0].second < p.second && p.first == 1) {
            ans -= map[i];
            map[i] = 0;
            break;
          }
        }
      }
      map[i + 1] += map[i];
      map[i] = 0;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (!board[i]) break;
    if (which[s[i] - 'A'][0].first == 2) {
      if (i == n - 1) {
        ans--;
        map[i] = 0;
      } else if (board[i + 1] == true) {
        ans -= map[i];
        map[i] = 0;
      }
    } else {
      if (i == 0) break;
      if (which[s[i - 1] - 'A'][0].first == 1 &&
          which[s[i] - 'A'][0].second > which[s[i - 1] - 'A'][0].second) {
        for (auto p : which[s[i - 1] - 'A']) {
          if (which[s[i] - 'A'][0].second < p.second && p.first == 1) break;
          if (which[s[i] - 'A'][0].second < p.second && p.first == 2) {
            ans -= map[i];
            map[i] = 0;
            break;
          }
        }
      }
      map[i - 1] += map[i];
      map[i] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
