#include <bits/stdc++.h>
using namespace std;

const int INF = 0x3f3f3f3f;
typedef complex<double> P;

int main(){
    int N, W, D;
    cin >> N >> W >> D;
    int L = 2 * (W + D);
    P p1 = P(W, 0);
    P p2 = P(W, D);
    P p3 = P(0, D);
    P C = P(0, -1);
    
    //end, start
    vector<pair<int, int>> lines;
    
    for(int i=0; i<N; i++){
        int x, y; string f;
        cin >> x >> y >> f;
        P p = P(x, y);
        
        switch (f[0]) {
            case 'W':
                p = (p - p3) * C + p3;
            case 'N':
                p = (p - p2) * C + p2;
            case 'E':
                p = (p - p1) * C + p1;
            default:
                break;
        }
        lines.emplace_back(p.real()+p.imag(), p.real()-p.imag());
    }
    sort(lines.begin(), lines.end());
    
    int ans = INF;
    for(int s=0; s<N; s++){
        int tans = 0;
        for(int i=0; i<N; ){
            int p = lines[i].first;
            while(i<N && lines[i].second <= p) i++;
            tans++;
        }
        ans = min(ans, tans);
        
        lines[0].first += L;
        lines[0].second += L;
        sort(lines.begin(), lines.end());
    }
    cout << ans << endl;
    return 0;
}
### Prompt

Generate a CPP solution to 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;

const int INF = 0x3f3f3f3f;
typedef complex<double> P;

int main(){
    int N, W, D;
    cin >> N >> W >> D;
    int L = 2 * (W + D);
    P p1 = P(W, 0);
    P p2 = P(W, D);
    P p3 = P(0, D);
    P C = P(0, -1);
    
    //end, start
    vector<pair<int, int>> lines;
    
    for(int i=0; i<N; i++){
        int x, y; string f;
        cin >> x >> y >> f;
        P p = P(x, y);
        
        switch (f[0]) {
            case 'W':
                p = (p - p3) * C + p3;
            case 'N':
                p = (p - p2) * C + p2;
            case 'E':
                p = (p - p1) * C + p1;
            default:
                break;
        }
        lines.emplace_back(p.real()+p.imag(), p.real()-p.imag());
    }
    sort(lines.begin(), lines.end());
    
    int ans = INF;
    for(int s=0; s<N; s++){
        int tans = 0;
        for(int i=0; i<N; ){
            int p = lines[i].first;
            while(i<N && lines[i].second <= p) i++;
            tans++;
        }
        ans = min(ans, tans);
        
        lines[0].first += L;
        lines[0].second += L;
        sort(lines.begin(), lines.end());
    }
    cout << ans << endl;
    return 0;
}
```