#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, w, d;
P v[1002];


int main() {
    cin >> n >> w >> d;
    int l = 2 * d + 2 * w; 

    for (int i = 0; i < n; ++i) {
        int x, y;
        char f;
        cin >> x >> y >> f;
        int c, b;
        switch (f) {
            case 'N':
                c = x;
                b = d - y;
            break;
            case 'E':
                c = d - y + w;
                b = w - x;
            break;
            case 'S':
                c = w - x + w + d;
                b = y;
            break;
            case 'W':
                c = y + 2 * w + d;
                b = x;
            break;
        }
        
        // v[i] = (left end of view, right end of view)

        v[i] = P ((c - b + l) % l, (c + b + l) % l);
    } 

    // sort by the left end of view

    sort(v, v + n);

    int minc = 10000;
    for (int i = 0; i < n; ++i) {
        
        // Put a clock at the left end of i-th member's view

        int c = 1;
        int tmp = v[i].first;
        for (int j = 1; j < n; ++ j) {
            int k = (i - j + n) % n;

            int left = v[k].first;
            int right = v[k].second;
            if (left > right) right += l;
            if (left <= tmp && tmp <= right) continue;
            if (left - l <= tmp && tmp <= right - l) continue;

            c++;
            tmp = left;
        }
        
        if (c < minc) minc = c;
    }
    cout << minc << endl;
}
### Prompt

Please formulate a CPP solution to the following problem:

Example

Input

2 10 6
4 4 E
6 4 W


Output

2

### Response

```cpp
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, w, d;
P v[1002];


int main() {
    cin >> n >> w >> d;
    int l = 2 * d + 2 * w; 

    for (int i = 0; i < n; ++i) {
        int x, y;
        char f;
        cin >> x >> y >> f;
        int c, b;
        switch (f) {
            case 'N':
                c = x;
                b = d - y;
            break;
            case 'E':
                c = d - y + w;
                b = w - x;
            break;
            case 'S':
                c = w - x + w + d;
                b = y;
            break;
            case 'W':
                c = y + 2 * w + d;
                b = x;
            break;
        }
        
        // v[i] = (left end of view, right end of view)

        v[i] = P ((c - b + l) % l, (c + b + l) % l);
    } 

    // sort by the left end of view

    sort(v, v + n);

    int minc = 10000;
    for (int i = 0; i < n; ++i) {
        
        // Put a clock at the left end of i-th member's view

        int c = 1;
        int tmp = v[i].first;
        for (int j = 1; j < n; ++ j) {
            int k = (i - j + n) % n;

            int left = v[k].first;
            int right = v[k].second;
            if (left > right) right += l;
            if (left <= tmp && tmp <= right) continue;
            if (left - l <= tmp && tmp <= right - l) continue;

            c++;
            tmp = left;
        }
        
        if (c < minc) minc = c;
    }
    cout << minc << endl;
}
```