#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 syori(int x, int q, string s, char t[], char d[]) {
  for (int i = 0; i < (s.size()); ++i) {
    if (s[x] == t[i]) {
      if (d[i] == 'L') {
        x--;
      } else {
        x++;
      }
      if (x == -1) {
        return 1;
      }
      if (x == s.size()) {
        return 3;
      }
    }
  }
  return 2;
}
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q];
  char d[q];
  for (int i = 0; i < (q); ++i) {
    cin >> t[i] >> d[i];
  }
  int a[n];
  for (int i = 0; i < (n); ++i) {
    a[i] = -1;
  }
  int l = 0;
  int r = n - 1;
  while (true) {
    if (a[(l + r) / 2] == -1) {
      a[(l + r) / 2] = syori((l + r) / 2, q, s, t, d);
      if (a[(l + r) / 2] == 1) {
        for (int i = 0; i < ((l + r) / 2); ++i) {
          a[i] = 1;
        }
        l = (l + r) / 2 + 1;
      }
      if (a[(l + r) / 2] == 3) {
        for (int i = (l + r) / 2; i < n; ++i) {
          a[i] = 3;
        }
        r = (l + r) / 2 - 1;
      }
      if (a[(l + r) / 2] == 2) {
        r = (l + r) / 2 - 1;
      }
    } else {
      break;
    }
  }
  l = 0;
  r = n - 1;
  while (a[l] == 1 || a[l] == 2) {
    l++;
  }
  while (true) {
    a[(l + r) / 2] = syori((l + r) / 2, q, s, t, d);
    if (a[(l + r) / 2] == 2) {
      l = (l + r) / 2 + 1;
    }
    if (a[(l + r) / 2] == 3) {
      for (int i = (l + r) / 2; i < n; ++i) {
        a[i] = 3;
      }
      r = (l + r) / 2 - 1;
    }
    if (r < l) break;
  }
  int ans = n;
  for (int i = 0; i < (n); ++i) {
    if (a[i] == 1 || a[i] == 3) ans--;
  }
  cout << ans << endl;
  return 0;
}
