// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define rep(i,x,y) for(int i=(x);i<(y);++i)

#define mp(a,b) make_pair((a),(b))

#define debug(x) #x << "=" << (x)

 

#ifdef DEBUG

#define _GLIBCXX_DEBUG

#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl

#else

#define dump(x)

#endif



typedef long long int ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

//template<typename T> using vec=std::vector<T>;



const int INF=1<<30;

const long long int INF_=1LL<<58;

const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){

	os << "[";

	for (const auto &v : vec) {

		os << v << ",";

	}

	os << "]";

	return os;

}



const int mod=1e6+7;

bool slot[mod];



void Solve(){

	int n,m;

	string s;

	cin >> n >> m >> s;

	

	ull h[300001],pow[300001],b=1000000007;

	h[0]=0;

	pow[0]=1;

	rep(i,1,n+1){

		h[i]=h[i-1]*b+s[i-1];

		pow[i]=pow[i-1]*b;

	}



	//unordered_set<ull> slot;

	ull a[300001];

	int l=0,r=1,ans=0;

	rep(i,0,m){

		string q;

		cin >> q;

		

		int *d;

		if(q[0]=='L') d=&l;

		else d=&r;

		if(q[1]=='+') ++*d;

		else --*d;



		//slot.insert(h[r]-h[l]*pow[r-l]);

		a[i]=h[r]-h[l]*pow[r-l];

	}



	sort(a,a+m);

	cout << unique(a,a+m)-a << endl;

}



int main(){

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	Solve();

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1495491715580832x):
#include <bits/stdc++.h>

using namespace std;



#define rep(i,x,y) for(int i=(x);i<(y);++i)

#define debug(x) #x << "=" << (x)



#ifdef DEBUG

#define _GLIBCXX_DEBUG

#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl

#else

#define show(x)

#endif



typedef long long int ll;

typedef pair<int,int> pii;

template<typename T> using vec=std::vector<T>;



const int inf=1<<30;

const long long int infll=1LL<<62;

const double eps=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){

    os << "[";

    for (const auto &v : vec) {

    	os << v << ",";

    }

    os << "]";

    return os;

}





//base=9973,mod=999999937LL, 1000000007LL;

struct rolling_hash{

    int mnum;

	std::string str;

    long long int base;

	std::vector<long long int> mod;

    std::vector<vector<long long int>> hash,pow;



	rolling_hash(const std::string &str,long long int base,vector<long long int> mod):mnum(mod.size()),str(str),base(base),mod(mod){

		int size=str.size();

		hash=std::vector<std::vector<long long int>>(mnum,std::vector<long long int>(size+1));

		pow=std::vector<std::vector<long long int>>(mnum,std::vector<long long int>(size+1));



		for(int i=0; i<mnum; ++i){

            hash[i][0]=0;

            pow[i][0]=1;

        }

        for(int i=0; i<mnum; ++i){

            long long int m=mod[i];

    		for(int j=1; j<size+1; ++j){

    			pow[i][j]=pow[i][j-1]*base%m;

    			hash[i][j]=(hash[i][j-1]*base+str[j-1])%m;

    		}

        }

	}



	long long int compute_hash(int l,int r,int i){ //[l,r)

		return (hash[i][r]-hash[i][l]*pow[i][r-l]%mod[i]+mod[i])%mod[i];

	}



    bool match(int l,int r,const std::vector<long long int> &hs){

        for(int i=0; i<mnum; ++i) if(compute_hash(l,r,mod[i])!=hs[i]) return false;

        return true;

    }

};



void solve(){

    int n,m;

    string s;

    cin >> n >> m >> s;



    rolling_hash roriha(s,9973,{999999937LL, 1000000007LL});

    vector<pair<ll,ll>> v;

    int l=0,r=1;

    rep(i,0,m){

        string q;

        cin >> q;

        if(q=="R++") ++r;

        if(q=="R--") --r;

        if(q=="L++") ++l;

        if(q=="L--") --l;

        v.push_back(make_pair(roriha.compute_hash(l,r,0),roriha.compute_hash(l,r,1)));

    }

    sort(v.begin(),v.end());

    v.erase(unique(v.begin(),v.end()),v.end());

    cout << v.size() << endl;

}



int main(){

    std::cin.tie(0);

    std::ios::sync_with_stdio(false);

    cout.setf(ios::fixed);

    cout.precision(10);

    solve();

    return 0;

}