#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string f;
  cin >> f;
  vector<pair<char, char>> qq;
  for (int i = 0; i < q; ++i) {
    char t, d;
    cin >> t >> d;
    qq.push_back(make_pair(t, d));
  }
  int ls = 0;
  int le = n - 1;
  int rs = 0;
  int re = n - 1;
  while (le - ls > 1) {
    int m = (le + ls) / 2;
    int pos = m;
    for (int i = 0; i < q; ++i) {
      char t = qq[i].first;
      char d = qq[i].second;
      if (f[pos] == t) {
        if (d == 'L') {
          pos--;
        } else {
          pos++;
        }
      }
      if (pos < 0) {
        ls = m;
        break;
      } else if (pos > n - 1) {
        le = m;
        break;
      }
      if (i == q - 1) {
        le = m;
      }
    }
  }
  while (re - rs > 1) {
    int m = (re + rs) / 2;
    int pos = m;
    for (int i = 0; i < q; ++i) {
      char t = qq[i].first;
      char d = qq[i].second;
      if (f[pos] == t) {
        if (d == 'L') {
          pos--;
        } else {
          pos++;
        }
      }
      if (pos < 0) {
        rs = m;
        break;
      } else if (pos > n - 1) {
        re = m;
        break;
      }
      if (i == q - 1) {
        rs = m;
      }
    }
  }
  if (le == 1) {
    int pos = 0;
    for (int i = 0; i < q; ++i) {
      char t = qq[i].first;
      char d = qq[i].second;
      if (pos < n && pos > -1) {
        if (f[pos] == t) {
          if (d == 'L') {
            pos--;
          } else {
            pos++;
          }
        }
      }
      if (pos < 0) {
        break;
      }
      if (i == q - 1) {
        le = 0;
      }
    }
  }
  if (rs == n - 2) {
    int pos = n - 1;
    for (int i = 0; i < q; ++i) {
      char t = qq[i].first;
      char d = qq[i].second;
      if (pos < n && pos > -1) {
        if (f[pos] == t) {
          if (d == 'L') {
            pos--;
          } else {
            pos++;
          }
        }
      }
      if (pos > n - 1) {
        break;
      }
      if (i == q - 1) {
        rs = n - 1;
      }
    }
  }
  int ret = rs - le + 1;
  ret = max(ret, 0);
  cout << ret << endl;
  return 0;
}
