#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

template<typename T>
void chmin(T &a, T b) {
    a = min(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string S;
    cin >> S;
    vector<char> T(q), D(q);
    REP(i, 0, q) {
        cin >> T[i] >> D[i];
    }

    auto bin1 = [&]() {
        int l = 0, r = n - 1;
        int ans = 0;
        while (l <= r) {
            int mid = (l + r) / 2;
            int x = mid;
            bool ok = true;
            REP(i, 0, q) {
                if (S[x] == T[i]) {
                    x += (2 * (D[i] == 'R') - 1);
                }
                if (x < 0 || x >= n) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                r = mid - 1;
                ans = mid;
            } else {
                l = mid + 1;
            }
        }
        return ans;
    };

    auto bin2 = [&]() {
        int l = 0, r = n - 1;
        int ans = n - 1;
        while (l <= r) {
            int mid = (l + r) / 2;
            int x = mid;
            bool ok = true;
            REP(i, 0, q) {
                if (S[x] == T[i]) {
                    x += (2 * (D[i] == 'R') - 1);
                }
                if (x < 0 || x >= n) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                l = mid + 1;
                ans = mid;
            } else {
                r = mid - 1;
            }
        }
        return ans;
    };

    dump(bin2());
    dump(bin1());

    cout << max(0, bin2() - bin1() + 1) << endl;

    return 0;
}
