#include <bits/stdc++.h>
using namespace std;
int n, q;
string s;
char desire[100005];
char dir[100005];
bool valid[100005];
void solve() {
  cin >> n >> q >> s;
  for (int i = 0; i < q; i++) {
    cin.ignore();
    cin >> desire[i] >> dir[i];
  }
  {
    int lhs = -1;
    int rhs = n - 1;
    while (lhs != rhs) {
      int mid = (lhs + rhs + 1) / 2;
      int curr = mid;
      for (int i = 0; i < q && curr >= 0 && curr < n; i++) {
        if (desire[i] == s[curr]) {
          if (dir[i] == 'L')
            curr--;
          else
            curr++;
        }
      }
      if (curr < 0)
        lhs = mid;
      else
        rhs = mid - 1;
    }
    for (int i = 0; i <= lhs; i++) {
      valid[i] = true;
    }
  }
  {
    int lhs = 0;
    int rhs = n;
    while (lhs != rhs) {
      int mid = (lhs + rhs) / 2;
      int curr = mid;
      for (int i = 0; i < q && curr >= 0 && curr < n; i++) {
        if (desire[i] == s[curr]) {
          if (dir[i] == 'L')
            curr--;
          else
            curr++;
        }
      }
      if (curr >= n)
        rhs = mid;
      else
        lhs = mid + 1;
    }
    for (int i = lhs; i < n; i++) {
      valid[i] = true;
    }
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    ret += valid[i];
  }
  cout << n - ret << "\n";
}
void casesolve() {
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
