#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int w,h,n;
  cin>>n>>w>>h;
  int x,y,B=2*(w+h);
  char c;
  vector<P> m;
  for(int i=0;i<n;i++){
    cin>>x>>y>>c;
    if(c=='S')m.push_back(P((x-y+B)%B,x+y));
    if(c=='E')m.push_back(P(w+y-(w-x),w+y+(w-x)));
    if(c=='N')m.push_back(P(w+h+(w-x)-(h-y),w+h+(w-x)+(h-y)));
    if(c=='W')m.push_back(P(w*2+h+(h-y)-x,(w*2+h+(h-y)+x)%B));
  }

  for(int i=0;i<n;i++)swap(m[i].first,m[i].second);
  sort(m.begin(),m.end());
  for(int i=0;i<n;i++)swap(m[i].first,m[i].second);
  int ans=n;
  for(int i=0;i<n;i++){
    int tp=1,p=m[i].second;
    for(int j=0;j<n;j++){
      int s=m[(i+j)%n].first,g=m[(i+j)%n].second;
      if(s>g&&!(g<p&&p<s))continue;
      if(s<g&&s<=p&&p<=g)continue;
      tp++,p=g;
    }
    ans=min(tp,ans);
  }
  cout<<ans<<endl;
  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<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int w,h,n;
  cin>>n>>w>>h;
  int x,y,B=2*(w+h);
  char c;
  vector<P> m;
  for(int i=0;i<n;i++){
    cin>>x>>y>>c;
    if(c=='S')m.push_back(P((x-y+B)%B,x+y));
    if(c=='E')m.push_back(P(w+y-(w-x),w+y+(w-x)));
    if(c=='N')m.push_back(P(w+h+(w-x)-(h-y),w+h+(w-x)+(h-y)));
    if(c=='W')m.push_back(P(w*2+h+(h-y)-x,(w*2+h+(h-y)+x)%B));
  }

  for(int i=0;i<n;i++)swap(m[i].first,m[i].second);
  sort(m.begin(),m.end());
  for(int i=0;i<n;i++)swap(m[i].first,m[i].second);
  int ans=n;
  for(int i=0;i<n;i++){
    int tp=1,p=m[i].second;
    for(int j=0;j<n;j++){
      int s=m[(i+j)%n].first,g=m[(i+j)%n].second;
      if(s>g&&!(g<p&&p<s))continue;
      if(s<g&&s<=p&&p<=g)continue;
      tp++,p=g;
    }
    ans=min(tp,ans);
  }
  cout<<ans<<endl;
  return 0;
}
```