// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:math/extgcd.cpp>
namespace math {
    template <class T> T extgcd( T a, T b, T& x, T& y ) {
        for ( T u = y = 1, v = x = 0; a; ) {
            T q = b / a;
            std::swap( x -= q * u, u );
            std::swap( y -= q * v, v );
            std::swap( b -= q * a, a );
        }
        return b;
    }
}

// @snippet<sh19910711/contest:math/mod_inverse.cpp>
namespace math {
    template <class T> T mod_inverse( T a, T m ) {
        T x, y;
        extgcd( a, m, x, y );
        x %= m;
        while ( x < 0 )
            x += m;
        return x;
    }
}


// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;
    
    const int SIZE = 300011;
    int n, m;
    string s;
    string Q[SIZE];
    
    template <long long B, long long MOD> class RollingHash {
    public:
        typedef long long LL;
        LL hash;
        LL bases;
        LL mod;
        LL b_inv;
        std::deque<char> Q;
        RollingHash() {
            init();
        }
        void init() {
            hash = 0;
            bases = 1;
            b_inv = math::mod_inverse( B, MOD ) % MOD;
            Q.clear();
        }
        void pushBack( char c ) {
            hash = ( hash * B + c ) % MOD;
            bases = ( bases * B ) % MOD;
            Q.push_back(c);
        }
        void popBack() {
            char c = Q.back();
            hash = ( ( hash - c + 3 * MOD ) % MOD * b_inv ) % MOD;
            bases = ( bases * b_inv ) % MOD;
            Q.pop_back();
        }
        void pushFront( char c ) {
            hash = ( hash + ( c * bases ) % MOD ) % MOD;
            bases = ( bases * B ) % MOD;
            Q.push_front(c);
        }
        void popFront() {
            char c = Q.front();
            hash = ( hash - ( bases * b_inv * c ) % MOD + MOD ) % MOD;
            bases = ( bases * b_inv ) % MOD;
            Q.pop_front();
        }
        void init( string s ) {
            int n = s.size();
            for ( int i = 0; i < n; ++ i ) {
                pushBack(s[i]);
            }
        }
    };
    RollingHash<47LL, 664579LL> rh1;
    RollingHash<53LL, 5761455LL> rh2;
    
    void push_front( char c ) {
        rh1.pushFront(c);
        rh2.pushFront(c);
    }
    
    void pop_front() {
        rh1.popFront();
        rh2.popFront();
    }
    
    void push_back( char c ) {
        rh1.pushBack(c);
        rh2.pushBack(c);
    }
    
    void pop_back() {
        rh1.popBack();
        rh2.popBack();
    }
    
    class Solution: public ISolution {
    public:
        void init() {
            rh1.init();
            rh2.init();
        }
        bool input() {
            if ( ! ( cin >> n >> m ) )
                return false;
            cin >> s;
            for ( int i = 0; i < m; ++ i )
                cin >> Q[i];
            return true;
        }
        bool check( const int& l, const int& r ) {
            return l >= 0 && l <= r;
        }
        void solve() {
            for ( int i = 0; i < n; ++ i )
                s[i] = s[i] - 'a' + 1;

            set <pair<long long, long long> > S;
            string sub = s.substr( 0, 1 );
            push_back(s[0]);
            
            int l = 0, r = 0;
            for ( int i = 0; i < m; ++ i ) {
                string& q = Q[i];
                if ( q[0] == 'L' ) {
                    if ( q[1] == '+' ) {
                        l ++;
                        if ( check( l, r ) ) {
                            sub = sub.substr( 1 );
                            pop_front();
                        }
                    } else {
                        l --;
                        if ( check( l, r ) ) {
                            sub = s[l] + sub;
                            push_front( s[l] );
                        }
                    }
                } else {
                    if ( q[1] == '+' ) {
                        r ++;
                        if ( check( l, r ) ) {
                            sub += s[r];
                            push_back(s[r]);
                        }
                    } else {
                        r --;
                        if ( check( l, r ) ) {
                            sub = sub.substr( 0, sub.size() - 1 );
                            pop_back();
                        }
                    }
                }
                
                S.insert( make_pair( rh1.hash, rh2.hash ) );
            }

            cout << S.size() << endl;
        }
        int run() {
            while ( init(), input() ) {
                solve();
                output();
            }
            return 0;
        }
    };
}


// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 37428