#include <bits/stdc++.h>
using namespace std;
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First &first, Rest &...rest) {
  cin >> first;
  IN(rest...);
  return;
}
inline void OUT(void) {
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void OUT(First first, Rest... rest) {
  cout << first << " ";
  OUT(rest...);
  return;
}
template <typename T>
void vec_print(vector<T> VEC) {
  for (long long i = (long long)0; i < (long long)VEC.size(); ++i) {
    cout << VEC[i] << " ";
  }
  cout << "\n";
};
template <typename T>
void mat_print(vector<vector<T>> MAT) {
  for (long long i = (long long)0; i < (long long)MAT.size(); ++i) {
    for (long long j = (long long)0; j < (long long)MAT[i].size(); ++j) {
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};
template <typename CLASS1, typename CLASS2>
class HOGE {
 public:
  CLASS1 key;
  CLASS2 value;
  HOGE(void) { return; };
  HOGE(CLASS1 key, CLASS2 value) {
    this->key = key;
    this->value = value;
  };
  ~HOGE(void) { return; };
  void print(void) {
    cout << "key : " << key << ", value : " << value << "\n";
    return;
  };
  bool operator==(const HOGE &obj) { return (this->value == obj.value); };
  bool operator<(const HOGE &obj) { return (this->value < obj.value); };
  bool operator>(const HOGE &obj) { return (this->value > obj.value); };
};
template <typename CLASS1, typename CLASS2>
bool operator==(const HOGE<CLASS1, CLASS2> &hoge1,
                const HOGE<CLASS1, CLASS2> &hoge2) {
  return hoge1.value == hoge2.value;
};
template <typename CLASS1, typename CLASS2>
bool operator<(const HOGE<CLASS1, CLASS2> &hoge1,
               const HOGE<CLASS1, CLASS2> &hoge2) {
  return hoge1.value < hoge2.value;
};
template <typename CLASS1, typename CLASS2>
bool operator>(const HOGE<CLASS1, CLASS2> &hoge1,
               const HOGE<CLASS1, CLASS2> &hoge2) {
  return hoge1.value > hoge2.value;
};
constexpr int INF = (1 << 30);
constexpr long long INFLL = 1LL << 62;
constexpr long double EPS = 1e-12;
constexpr long long MOD = (long long)((1E+9) + 7);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, Q;
  IN(N, Q);
  string str;
  IN(str);
  vector<char> t(Q), d(Q);
  for (long long i = (long long)0; i < (long long)Q; ++i) IN(t[i], d[i]);
  long long left_pos = -1;
  long long left_max = -1;
  long long right_pos = N;
  long long right_min = N;
  for (long long i = (long long)Q - 1; i >= (long long)0; --i) {
    if (left_pos + 1 < N) {
      if (t[i] == str[left_pos + 1] && d[i] == 'L') {
        left_pos += 1;
      }
    }
    if (left_pos - 1 >= 0) {
      if (t[i] == str[left_pos - 1] && d[i] == 'R') {
        left_pos -= 1;
      }
    }
    if (right_pos + 1 < N) {
      if (t[i] == str[right_pos + 1] && d[i] == 'L') {
        right_pos += 1;
      }
    }
    if (right_pos - 1 >= 0) {
      if (t[i] == str[right_pos - 1] && d[i] == 'R') {
        right_pos -= 1;
      }
    }
    left_max = max(left_max, left_pos);
    right_min = min(right_min, right_pos);
  }
  if (left_max >= right_min) {
    OUT(N);
    return 0;
  }
  OUT(N - ((N - right_min) + (left_max + 1)));
  return 0;
}
