#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
set<P> st;
ll N,K;
string s;
ll ans=0;
P check(){
	P p;
	p.fr=p.sc=0;
	rep(i,N){
		if(s[i]=='N') p.sc++;
		else if(s[i]=='W') p.fr--;
		else if(s[i]=='S') p.sc--;
		else p.fr++;
	}
	return p;
}

void solve1(){

	P ps;
	st.insert(ps);
	rep(i,N){
		if(s[i]=='N') ps.sc++;
		else if(s[i]=='W') ps.fr--;
		else if(s[i]=='S') ps.sc--;
		else ps.fr++;
		st.insert(ps);
	}
	set<P>::iterator ite;
	for(ite=st.begin();ite!=st.end();++ite){
		P p=*ite;
		if(st.count(P(p.fr+1,p.sc))&&st.count(P(p.fr,p.sc+1))&&st.count(P(p.fr+1,p.sc+1))) ans++;
	}
	cout<<ans<<endl;
}
struct T{
	ll x,y,m;
	bool operator<(const T& an)const{
		if(x!=an.x) return x<an.x;
		if(y!=an.y) return y<an.y;
		return m<an.m;
	}
	bool operator>(const T& an)const{
		if(x!=an.x) return x>an.x;
		if(y!=an.y) return y>an.y;
		return m>an.m;
	}
	bool operator==(const T& an)const{
		if(x!=an.x) return 0;
		if(y!=an.y) return 0;
		return m==an.m;
	}
};
vector<T> G;
vector<P> V[100000];
map<P,ll> mp;
P vec;
ll vx,vy;
ll cnt;
ll V_SIZE;
const ll INF=0xffffffffffffff;
bool ok(P now,ll id,bool b){
	if(b){
		now.fr++;
		now.sc++;
	}
	ll ID=upper_bound(V[id].begin(),V[id].end(),P(now.fr,INF))-V[id].begin();
	if(ID==0) return 0;
	if(V[id][ID-1].sc>=now.sc) return 1;
	return 0;
}

int main()
{
	cin>>N>>K;
	cin>>s;
	vec=check();
	if(K==1||(vec.fr==0&&vec.sc==0)){
		solve1();
		return 0;
	}	
	while(vec.fr<=0||vec.sc<0){
		rep(i,N){
			if(s[i]=='N') s[i]='W';
			else if(s[i]=='W') s[i]='S';
			else if(s[i]=='S') s[i]='E';
			else s[i]='N';
		}
		vec=check();
	}
	vx=vec.fr;
	vy=vec.sc;
	P p=P(0,0);
	G.pb(T{0,0,0});
	//cout<<vx<<" "<<vy<<endl;
	rep(i,N){
		if(s[i]=='N') p.sc++;
		else if(s[i]=='W') p.fr--;
		else if(s[i]=='S') p.sc--;
		else p.fr++;
		if(p.fr>=0){
			G.pb(T{p.fr%vx,p.sc-(p.fr/vx)*vy,p.fr/vx});
		}
		else{
			ll m=((p.fr+1)/vx)-1;
			G.pb(T{(p.fr%vx+vx)%vx,p.sc-m*vy,m});
		}
	}
	sort(G.begin(),G.end());
	G.erase(unique(G.begin(),G.end()),G.end());
	V_SIZE=0;
	rep(i,G.size()){
		if(i>0&&G[i].x==G[i-1].x&&G[i].y==G[i-1].y){
			p=V[V_SIZE-1][V[V_SIZE-1].size()-1];
			if(G[i].m<=p.sc){
				V[V_SIZE-1][V[V_SIZE-1].size()-1].sc=G[i].m+K;
			}
			else{
				V[V_SIZE-1].pb(P(G[i].m,G[i].m+K));
			}
		}
		else{
			mp[P(G[i].x,G[i].y)]=V_SIZE;
			V[V_SIZE].pb(P(G[i].m,G[i].m+K));//[)
			V_SIZE++;
		}
	}
	ll id,id2,id3,id4;
	for(auto ite=mp.begin();ite!=mp.end();++ite){
		ll nx=ite->fr.fr;
		ll ny=ite->fr.sc;
		id=ite->sc;
		auto itr=ite;
		if(nx==vx-1){
			itr=mp.find(P(0,ny-vy));
			if(itr==mp.end()) continue;
			id2=itr->sc;
			itr=mp.find(P(nx,ny+1));
			if(itr==mp.end()) continue;
			id3=itr->sc;
			itr=mp.find(P(0,ny+1-vy));
			if(itr==mp.end()) continue;
			id4=itr->sc;
			cnt=1;
		}
		else{	
			itr=mp.find(P(nx+1,ny));
			if(itr==mp.end()) continue;
			id2=itr->sc;
			itr=mp.find(P(nx,ny+1));
			if(itr==mp.end()) continue;
			id3=itr->sc;
			itr=mp.find(P(nx+1,ny+1));
			if(itr==mp.end()) continue;
			id4=itr->sc;
			cnt=0;
		}
		vector<ll> fs;
		rep(j,V[id].size()){
			fs.pb(V[id][j].fr);
			fs.pb(V[id][j].sc);
		}
		rep(j,V[id2].size()){
			fs.pb(V[id2][j].fr-cnt);
			fs.pb(V[id2][j].sc-cnt);
		}
		rep(j,V[id3].size()){
			fs.pb(V[id3][j].fr);
			fs.pb(V[id3][j].sc);
		}
		rep(j,V[id4].size()){
			fs.pb(V[id4][j].fr-cnt);
			fs.pb(V[id4][j].sc-cnt);
		}
		sort(fs.begin(),fs.end());
		fs.erase(unique(fs.begin(),fs.end()),fs.end());
		
		rep(j,fs.size()-1){
			P now=P(fs[j],fs[j+1]);
			if(ok(now,id,0)&&ok(now,id2,cnt)&&ok(now,id3,0)&&ok(now,id4,cnt)){
				ans+=now.sc-now.fr;
			}
		}
		fs.clear();
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16932