#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<P> v;
bool comp(P a, P b) {
	if (a.second != b.second)return a.second < b.second;
	return a.first < b.first;
}
int n, w, h;
bool inc(int id, int s) {
	int le = v[id].first, ri = v[id].second;
	for (int i = -2; i <= 2; i++) {
		int ss = s + i * 2 * (w + h);
		if (le <= ss && ss <= ri)return true;
	}
	return false;
}
void solve() {
	cin >> n >> w >> h;
	rep(i, n) {
		int x, y; char t; cin >> x >> y >> t; y = h - y;
		swap(x, y);
		int le, ri;
		if (t == 'N') {
			le = y - x;
			ri = y + x;
		}
		else if (t == 'S') {
			le = h + w + w - y - (h - x);
			ri = h + w + w - y + h - x;
		}
		else if (t == 'E') {
			le = w + x - (w - y);
			ri = w + x + w - y;
		}
		else {
			le = w + h + w + h-x - y;
			ri = w + h + w + h-x + y;
		}
		v.push_back({ le,ri });
		//cout << le << " " << ri << endl;
	}
	int ans = 2 * n;
	rep(i, n) {
		int s = v[i].second;
		vector<P> u;
		rep(j, n) {
			if (inc(j, s))continue;
			int le = v[j].first - s;
			int ri = v[j].second - s;
			while (le < 0) {
				le += 2 * (w + h);
				ri += 2 * (w + h);
			}
			u.push_back({ le,ri });
		}
		sort(u.begin(), u.end(), comp);
		int cnt = 1, loc = 0;
		rep(j, u.size()) {
			if (loc < u[j].first) {
				cnt++; loc = u[j].second;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


### Prompt

Please provide a Cpp coded solution to the problem described below:

Example

Input

2 10 6
4 4 E
6 4 W


Output

2

### Response

```cpp
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<P> v;
bool comp(P a, P b) {
	if (a.second != b.second)return a.second < b.second;
	return a.first < b.first;
}
int n, w, h;
bool inc(int id, int s) {
	int le = v[id].first, ri = v[id].second;
	for (int i = -2; i <= 2; i++) {
		int ss = s + i * 2 * (w + h);
		if (le <= ss && ss <= ri)return true;
	}
	return false;
}
void solve() {
	cin >> n >> w >> h;
	rep(i, n) {
		int x, y; char t; cin >> x >> y >> t; y = h - y;
		swap(x, y);
		int le, ri;
		if (t == 'N') {
			le = y - x;
			ri = y + x;
		}
		else if (t == 'S') {
			le = h + w + w - y - (h - x);
			ri = h + w + w - y + h - x;
		}
		else if (t == 'E') {
			le = w + x - (w - y);
			ri = w + x + w - y;
		}
		else {
			le = w + h + w + h-x - y;
			ri = w + h + w + h-x + y;
		}
		v.push_back({ le,ri });
		//cout << le << " " << ri << endl;
	}
	int ans = 2 * n;
	rep(i, n) {
		int s = v[i].second;
		vector<P> u;
		rep(j, n) {
			if (inc(j, s))continue;
			int le = v[j].first - s;
			int ri = v[j].second - s;
			while (le < 0) {
				le += 2 * (w + h);
				ri += 2 * (w + h);
			}
			u.push_back({ le,ri });
		}
		sort(u.begin(), u.end(), comp);
		int cnt = 1, loc = 0;
		rep(j, u.size()) {
			if (loc < u[j].first) {
				cnt++; loc = u[j].second;
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


```