#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool setmin(T& a, T b) {
  if (b < a) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <typename T>
bool setmax(T& a, T b) {
  if (b > a) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <typename T>
bool setmineq(T& a, T b) {
  if (b <= a) {
    a = b;
    return true;
  } else {
    return false;
  }
}
template <typename T>
bool setmaxeq(T& a, T b) {
  if (b >= a) {
    a = b;
    return true;
  } else {
    return false;
  }
}
long long signed int mo(long long signed int a, long long signed int b) {
  assert(b > 0);
  a %= b;
  if (a < 0) {
    a += b;
  }
  return a;
}
long long signed int fl(long long signed int a, long long signed int b) {
  assert(b > 0);
  return (a > 0 ? a / b : (a - b + 1) / b);
}
long long signed int ce(long long signed int a, long long signed int b) {
  assert(b > 0);
  return (a < 0 ? a / b : (a + b - 1) / b);
}
int n, q;
string s, t[200000], d[200000];
bool f(int p) {
  for (int i = (0); i < (q); ++i) {
    assert(((1) <= (p) && (p) < (n)));
    if (s[p - 1] == t[i][0]) {
      if (d[i] == "L") {
        p--;
      } else {
        p++;
      }
    }
    if (p == 0) {
      return true;
    }
    if (p == n) {
      return false;
    }
  }
  return false;
}
bool g(int p) {
  for (int i = (0); i < (q); ++i) {
    assert(((1) <= (p) && (p) < (n)));
    if (s[p] == t[i][0]) {
      if (d[i] == "L") {
        p--;
      } else {
        p++;
      }
    }
    if (p == 0) {
      return false;
    }
    if (p == n) {
      return true;
    }
  }
  return false;
}
int main() {
  cin >> n >> q >> s;
  for (int i = (0); i < (q); ++i) {
    cin >> t[i] >> d[i];
  }
  int x1;
  {
    int L = 0, H = n;
    while (H - L > 1) {
      int M = (L + H) / 2;
      (f(M) ? L : H) = M;
    }
    x1 = L;
  }
  int x2;
  {
    int L = 0, H = n;
    while (H - L > 1) {
      int M = (L + H) / 2;
      (g(M) ? H : L) = M;
    }
    x2 = H;
  }
  cout << x2 - x1 << endl;
  return 0;
}
