#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF = (long long)1E17;
long mod(long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
using namespace std;
bool prime_(int n) {
  if (n == 1) {
    return false;
  } else if (n == 2) {
    return true;
  } else {
    for (int i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}
long long gcd_(long long a, long long b) {
  if (a < b) {
    swap(a, b);
  }
  if (a % b == 0) {
    return b;
  } else {
    return gcd_(b, a % b);
  }
}
long long lcm_(long long x, long long y) { return (x / gcd_(x, y)) * y; }
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  char t[q], d[q];
  for (int i = 0; i < q; i++) {
    cin >> t[i] >> d[i];
  }
  int l = 0, r = n + 1;
  int left, right;
  bool flag;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int current = m;
    flag = true;
    for (int i = 0; i < q; i++) {
      if (current < 0 || current >= n) {
        flag = false;
        break;
      }
      if (s[current] == t[i]) {
        if (d[i] == 'L') {
          current--;
          if (current == -1) {
            flag = false;
            break;
          }
        } else {
          current++;
          if (current == n) {
            flag = false;
            break;
          }
        }
      }
    }
    if (flag) {
      r = m + 1;
    } else {
      l = m + 1;
    }
    if (r - l == 2) {
      flag = true;
      current = l;
      for (int i = 0; i < q; i++) {
        if (current < 0 || current >= n) {
          flag = false;
          break;
        }
        if (s[current] == t[i]) {
          if (d[i] == 'L') {
            current--;
            if (current == -1) {
              flag = false;
              break;
            }
          } else {
            current++;
            if (current == n) {
              flag = false;
              break;
            }
          }
        }
      }
      if (flag) {
        r = m;
      } else {
        l = m;
      }
    }
  }
  left = l;
  l = -1;
  r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    int current = m;
    flag = true;
    for (int i = 0; i < q; i++) {
      if (current < 0 || current >= n) {
        flag = false;
        break;
      }
      if (s[current] == t[i]) {
        if (d[i] == 'L') {
          current--;
          if (current == -1) {
            flag = false;
            break;
          }
        } else {
          current++;
          if (current == n) {
            flag = false;
            break;
          }
        }
      }
    }
    if (flag) {
      l = m - 1;
    } else {
      r = m - 1;
    }
    if (r - l == 2) {
      flag = true;
      current = r;
      for (int i = 0; i < q; i++) {
        if (current < 0 || current >= n) {
          flag = false;
          break;
        }
        if (s[current] == t[i]) {
          if (d[i] == 'L') {
            current--;
            if (current == -1) {
              flag = false;
              break;
            }
          } else {
            current++;
            if (current == n) {
              flag = false;
              break;
            }
          }
        }
      }
      if (flag) {
        l = m;
      } else {
        r = m;
      }
    }
  }
  right = r;
  int ans;
  if (l <= r) {
    ans = r - l + 1;
  } else {
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}
