#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;
            if(binary_search(route, route + N + 1, Pi(y + 1, x)) && binary_search(route, route + N + 1, Pi(y, x + 1)) && binary_search(route, route + N + 1, 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 rp = Pi(iy - plus * vecy, (ix + 1) % vecx);
        Pi up = Pi(iy + 1, ix);
        Pi rup = Pi(iy + 1 - plus * vecy, (ix + 1) % vecx);
        Pi ip = data[i].first;
        Pi nop = Pi(-LLINF, -LLINF);

        r = lower_bound(data.begin(), data.end(), PPi(rp, nop)) - data.begin();
        u = lower_bound(data.begin(), data.end(), PPi(up, nop)) - data.begin();
        ru = lower_bound(data.begin(), data.end(), PPi(rup, nop)) - data.begin();
        while(i < data.size() && data[i].first == ip) {
            ll s = data[i].second.first, t = data[i].second.second;
            comp.push_back(s); comp.push_back(t);
            d.push_back(Ti(1, Pi(0, s)));
            d.push_back(Ti(-1, Pi(0, t)));
            i++;
        }
        while(r < data.size() && data[r].first == rp) { 
            ll s = data[r].second.first - plus, t = data[r].second.second - plus;
            comp.push_back(s); comp.push_back(t);
            d.push_back(Ti(1, Pi(1, s)));
            d.push_back(Ti(-1, Pi(1, t)));
            r++;
        }
        while(u < data.size() && data[u].first == up) { 
            ll s = data[u].second.first, t = data[u].second.second;
            comp.push_back(s); comp.push_back(t);
            d.push_back(Ti(1, Pi(2, s)));
            d.push_back(Ti(-1, Pi(2, t)));
            u++;
        }
        while(ru < data.size() && data[ru].first == rup) { 
            ll s = data[ru].second.first - plus, t = data[ru].second.second - plus;
            comp.push_back(s); comp.push_back(t);
            d.push_back(Ti(1, Pi(3, s)));
            d.push_back(Ti(-1, Pi(3, t)));
            ru++;
        }
        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];
        } 
    }
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 25272