#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const long long int mod = 1000000007;
const long long int big = 2.19e15 + 1;
const long double pai = 3.141592653589793238462643383279502884197;
const long double eps = 1e-15;
template <class T, class U>
bool mineq(T& a, U b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
bool maxeq(T& a, U b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long int gcd(long long int a, long long int b) {
  if (a % b == 0) {
    return b;
  } else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  if (a == 0) {
    return b;
  }
  return a / gcd(a, b) * b;
}
template <class T>
void SO(T& ve) {
  sort(ve.begin(), ve.end());
}
template <class T>
void REV(T& ve) {
  reverse(ve.begin(), ve.end());
}
template <class T>
long long int LBI(vector<T>& ar, T in) {
  return lower_bound(ar.begin(), ar.end(), in) - ar.begin();
}
template <class T>
long long int UBI(vector<T>& ar, T in) {
  return upper_bound(ar.begin(), ar.end(), in) - ar.begin();
}
int main(void) {
  int n, Q, i;
  cin >> n >> Q;
  string s;
  cin >> s;
  s.push_back('#');
  s.insert(s.begin(), '#');
  vector<pair<char, char>> ma(Q);
  for (i = 0; i < Q; i++) {
    char c, d;
    cin >> c >> d;
    ma[i] = make_pair(c, d);
  }
  int bmin = 0, bmax = n, ans = n;
  while (bmax - bmin > 1) {
    int bgen = (bmin + bmax) / 2, x = bgen;
    for (auto it : ma) {
      if (s[x] == it.first) {
        if (it.second == 'L') {
          x--;
        } else {
          x++;
        }
      }
    }
    if (x == 0) {
      bmin = bgen;
    } else {
      bmax = bgen;
    }
  }
  ans -= bmin;
  bmin = 1;
  bmax = n + 1;
  while (bmax - bmin > 1) {
    int bgen = (bmin + bmax) / 2, x = bgen;
    for (auto it : ma) {
      if (s[x] == it.first) {
        if (it.second == 'L') {
          x--;
        } else {
          x++;
        }
      }
    }
    if (x == n + 1) {
      bmax = bgen;
    } else {
      bmin = bgen;
    }
  }
  ans -= n + 1 - bmax;
  maxeq(ans, 0);
  cout << ans << endl;
  return 0;
}
