#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair < ll , ll > Pi;
typedef pair < Pi , Pi > PPi;
typedef pair < ll , Pi > Ti;
const ll LLINF = 1LL << 60;
const int INF = (1 << 30) - 1;

char ch[] = "NESW";
ll dy[] = {-1, 0, 1, 0};
ll dx[] = {0, 1, 0, -1};

ll llabs(ll n) { return (n < 0 ? -n : n); }

ll N, K;
string S;
Pi route[200005];
ll vecy = 0, vecx = 0;
vector < PPi > data;
ll ans = 0;
ll sum[4][200005];
int main()
{
    cin >> N >> K >> S;
    for(int i = 0; i < N; i++) {
        int j = 0;
        while(S[i] != ch[j]) j++;
        vecy += dy[j], vecx += dx[j];
        route[i + 1] = Pi(vecy, vecx);
    }
    route[0] = Pi(INF, 2 * N);
    for(int i = 1; i <= N; i++) {
        if(vecy < 0) route[i].first = -route[i].first;
        if(vecx < 0) route[i].second = -route[i].second;
        if(vecx == 0) swap(route[i].first, route[i].second);
        route[i].first += INF, route[i].second += N * 2;
    }
    vecy = llabs(vecy); vecx = llabs(vecx);
    if(vecx == 0) vecx = vecy, vecy = 0;
    sort(route, route + N + 1);
    if(vecx == 0) {
        for(int i = 0; i <= N;) {
            ll y = route[i].first, x = route[i].second;
            Pi *a = route, *b = route + N + 1;
            if(binary_search(a, b, Pi(y + 1, x)) && binary_search(a, b, Pi(y, x + 1)) && binary_search(a, b, Pi(y + 1, x + 1))) ans++;
            while(i <= N && route[i].first == y && route[i].second == x) i++;
        }
        cout << ans << endl;
        return (0);
    }
    for(int i = 0; i <= N; i++) {
        ll y = route[i].first, x = route[i].second;
        data.push_back(PPi(Pi(y - x / vecx * vecy, x % vecx), Pi(x / vecx, x / vecx + K)));
    }
    sort(data.begin(), data.end());
    data.erase(unique(data.begin(), data.end()), data.end());
    for(int i = 0; i < data.size();) {
        vector < ll > comp;
        vector < Ti > d;
        map < ll, ll > conv;
        
        ll now[4] = {};

        ll r, u, ru;
        ll iy = data[i].first.first, ix = data[i].first.second;
        ll plus = (ix + 1) / vecx;
        Pi pp[4] = {data[i].first, Pi(iy - plus * vecy, (ix + 1) % vecx), Pi(iy + 1, ix), Pi(iy + 1 - plus * vecy, (ix + 1) % vecx)};
        Pi nop = Pi(-LLINF, -LLINF);
        ll pos[4];
        pos[0] = i;
        for(int j = 1; j < 4; j++) pos[j] = lower_bound(data.begin(), data.end(), PPi(pp[j], nop)) - data.begin();
        for(int j = 0; j < 4; j++) {
            while(pos[j] < data.size() && data[pos[j]].first == pp[j]) {
                ll s = data[pos[j]].second.first - plus * (j % 2) , t = data[pos[j]].second.second - plus * (j % 2);
                comp.push_back(s); comp.push_back(t);
                d.push_back(Ti(1, Pi(j, s)));
                d.push_back(Ti(-1, Pi(j, t)));
                pos[j]++;
            }
        }
        sort(comp.begin(), comp.end());
        comp.erase(unique(comp.begin(), comp.end()), comp.end());
        for(int j = 0; j < comp.size(); j++) conv[comp[j]] = j;
        for(int p = 0; p < 4; p++) for(int j = 0; j < comp.size(); j++) sum[p][j] = 0;
        for(int j = 0; j < d.size(); j++) sum[d[j].second.first][conv[d[j].second.second]] += d[j].first;
        for(int j = 0; j < comp.size() - 1; j++) {
            bool flag = true;
            for(int k = 0; k < 4; k++) {
                now[k] += sum[k][j];
                if(now[k] <= 0) flag = false;
            }
            if(flag) ans += comp[j + 1] - comp[j];
        }
        i = pos[0];
    }
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 25312