#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const int N = 100;
int n, m;
int x, y;
string s;
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C, x = sr, y = sc;
for (int i = 0; i < M; i++) {
s += S[i];
}
}
int colour(int ar, int ac, int br, int bc) {
vector<vector<int>> vis(N, vector<int>(N));
vis[x][y] = 1;
int nx = x, ny = y;
for (char c : s) {
if (c == 'N') {
nx--;
} else if (c == 'S') {
nx++;
} else if (c == 'W') {
ny--;
} else {
ny++;
}
vis[nx][ny] = 1;
}
int ans = 0;
for (int i = ar; i <= br; i++) {
for (int j = ac; j <= bc; j++) {
if (vis[i][j]) continue;
vector<pair<int, int>> que(1, {i, j});
ans++;
vis[i][j] = 1;
for (int b = 0; b < int(que.size()); b++) {
auto [x, y] = que[b];
for (int k = 0; k < 4; k++) {
int Nx = x + dx[k];
int Ny = y + dy[k];
if (ar <= Nx && Nx <= br && ac <= Ny && Ny <= bc && !vis[Nx][Ny]) {
vis[Nx][Ny] = 1;
que.emplace_back(Nx, Ny);
}
}
}
}
}
return ans;
}