#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n, w, h;
	cin >> n >> w >> h;
	vector<pii> v;
	REP(i, n)
	{
		int x, y; char d;
		cin >> x >> y >> d;
		if (d == 'W')
		{
			int rh = x;
			int r = y + rh;
			int l = y - rh;
			v.emplace_back(r, l);
		}
		if (d == 'N')
		{
			int rh = h - y;
			int r = h + x + rh;
			int l = h + x - rh;
			v.emplace_back(r, l);
		}
		if (d == 'E')
		{
			int rh = w - x;
			int r = h + w + (h - y) + rh;
			int l = h + w + (h - y) - rh;
			v.emplace_back(r, l);
		}
		if (d == 'S')
		{
			int rh = y;
			int r = h * 2 + w + (w - x) + rh;
			int l = h * 2 + w + (w - x) - rh;
			v.emplace_back(r, l);
		}
	}
	sort(ALL(v));
	int len = (h + w) * 2;
	int ans = INF;
	REP(i, n)
	{
		auto tv = v;
		REP(j, n)
		{
			if (tv[j].first < v[i].first)
			{
				tv[j].first += len;
				tv[j].second += len;
			}
		}
		sort(ALL(tv));
		int tmp = tv[0].first;
		int cnt = 1;
		REP(j, n)
		{
			if (tv[j].second > tmp)
			{
				tmp = tv[j].first;
				cnt++;
			}
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}
### Prompt

Create a solution in Cpp for the following problem:

Example

Input

2 10 6
4 4 E
6 4 W


Output

2

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false);
	int n, w, h;
	cin >> n >> w >> h;
	vector<pii> v;
	REP(i, n)
	{
		int x, y; char d;
		cin >> x >> y >> d;
		if (d == 'W')
		{
			int rh = x;
			int r = y + rh;
			int l = y - rh;
			v.emplace_back(r, l);
		}
		if (d == 'N')
		{
			int rh = h - y;
			int r = h + x + rh;
			int l = h + x - rh;
			v.emplace_back(r, l);
		}
		if (d == 'E')
		{
			int rh = w - x;
			int r = h + w + (h - y) + rh;
			int l = h + w + (h - y) - rh;
			v.emplace_back(r, l);
		}
		if (d == 'S')
		{
			int rh = y;
			int r = h * 2 + w + (w - x) + rh;
			int l = h * 2 + w + (w - x) - rh;
			v.emplace_back(r, l);
		}
	}
	sort(ALL(v));
	int len = (h + w) * 2;
	int ans = INF;
	REP(i, n)
	{
		auto tv = v;
		REP(j, n)
		{
			if (tv[j].first < v[i].first)
			{
				tv[j].first += len;
				tv[j].second += len;
			}
		}
		sort(ALL(tv));
		int tmp = tv[0].first;
		int cnt = 1;
		REP(j, n)
		{
			if (tv[j].second > tmp)
			{
				tmp = tv[j].first;
				cnt++;
			}
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}
```