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