#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <cassert>

using namespace std;
typedef long long ll;

#define N 100000
#define M 200010
#define LLINF 2000000000000000000LL

map<pair<ll,ll>,int> mm;
vector<pair<ll,ll> > vec[N+1]; 

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

int n,k;
ll p[N],q[N],s[N],t[N];
char step[N+1];

void ans1(){
  ll x = 0;
  ll y = 0;
  ll ans = 0;
  map<pair<ll,ll>,int> mm;
  set<pair<ll,ll> > visited;
  
  for(int j=0;j<4;j++){
    mm[make_pair(x+dx[j],y+dy[j])]++;
  }
  visited.insert({0,0});

  for(int i=0;i<n;i++){
    if(step[i]=='E') x++;
    if(step[i]=='W') x--;
    if(step[i]=='N') y++;
    if(step[i]=='S') y--;
    
    if(visited.find(make_pair(x,y)) != visited.end()) continue;
    visited.insert(make_pair(x,y));
    
    for(int j=0;j<4;j++){
      mm[make_pair(x+dx[j],y+dy[j])]++;
      
      if(mm[make_pair(x+dx[j],y+dy[j])]==4){
	ans++;
      }
    }
  }

  printf("%lld\n",ans);
}

int main(){
  
  scanf("%d%d%s",&n,&k,step);

  ll a=0,b=0;
  
  for(int i=0;i<n;i++){
    p[i] = a;
    q[i] = b;
    
    if(step[i]=='E') a++;
    if(step[i]=='W') a--;
    if(step[i]=='N') b++;
    if(step[i]=='S') b--;
  }

  for(int i=0;i<n;i++){
    if(a < 0) p[i]*=-1;
    p[i] += N;
    if(b < 0) q[i]*=-1;
    q[i] += N;
  }
  
  a = abs(a);
  b = abs(b);

  if(a==0){
    if(b==0){
      ans1();
      return 0;
    }

    for(int i=0;i<n;i++){
      swap(p[i],q[i]);
    }
    swap(a,b);
  }
      
  int g = 1;
  
  for(int i=0;i<n;i++){
    // [s,t)
    s[i] = p[i]/a;
    t[i] = s[i]+k+(i==0);

    p[i] -= a * s[i];
    q[i] -= b * s[i];

    auto it = mm.find(make_pair(p[i],q[i]));
    
    if(it==mm.end()){
      mm[make_pair(p[i],q[i])] = g;
      vec[g].push_back({s[i],t[i]});
      g++;
    }else{
      vec[it->second].push_back({s[i],t[i]});
    }
  }

  for(int i=1;i<g;i++){
    if(vec[i].empty()) continue;
    
    sort(vec[i].begin(),vec[i].end());

    for(int j=1;j<vec[i].size();j++){
      vec[i][j].first = max(vec[i][j-1].second,vec[i][j].first);
    }
  }

  ll ans = 0;

  for(auto it = mm.begin();it!=mm.end();it++){
    int ar[4]={},plus[4]={};
    
    for(int i=0;i<4;i++){
      ll p1 = (it->first.first)+dx[i],p2 = (it->first.second)+dy[i];
      
      if(0<= p1 && p1 < a){
	plus[i] = 0;
      }else{
	p1 = p1%a;
	p2 -= b;
	plus[i] = -1;
      }

      auto it2 = mm.find({p1,p2});
      
      if(it2==mm.end()){
	ar[i] = 0;
      }else{
	ar[i] = it2->second;
      }
    }

    if(ar[0]==0 || ar[1]==0 || ar[2]==0 || ar[3]==0) continue;

    vector<pair<ll,ll> > vec_all;
    
    for(int i=0;i<4;i++){
      for(int j=0;j<vec[ar[i]].size();j++){
	vec_all.push_back({vec[ar[i]][j].first+plus[i],vec[ar[i]][j].second+plus[i]});
      }
    }
    vec_all.push_back({LLINF,LLINF+1});
    sort(vec_all.begin(),vec_all.end());
    
    priority_queue<int> pq; 
    int cc = 0,st=0;
    
    for(int i=0;i<vec_all.size();i++){
      if(vec_all[i].first >= vec_all[i].second) continue;
      
      while(pq.size() && -pq.top() <= vec_all[i].first){
	if(cc==4){
	  ans += (-pq.top()) - st;
	}
	pq.pop();
	cc--;
      }

      pq.push(-vec_all[i].second);
      cc++;

      assert(cc<=4);

      if(cc==4){
	st = vec_all[i].first;
      }
    }
  }
    
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 18144