#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tpl;

const int MAX_N = 1001;

int N,W,D;
int XS[MAX_N];
int YS[MAX_N];
char AS[MAX_N];
bool used[MAX_N];
int main(){

  cin>>N>>W>>D;
  for(int i=0;i<N;i++)cin>>XS[i]>>YS[i]>>AS[i];
  vector<pii> poses;
  // ???????£????????????????, ??§?¨????????????????????????????
  for(int i=0;i<N;i++){

    // w,n,e,s?????????????????¶??????????£??????§????????¢
    const int wall_dist[4] = {XS[i], D - YS[i], W - XS[i], YS[i]};

    // nw,ne,se,sw?????????????????????????????????
    const int dy[] = {1, 1, -1, -1};
    const int dx[] = {-1, 1, 1, -1};
    
    // nw,ne,se,sw???????????§, ????????§?¨?????¨????????????????
    int stripex[4],stripey[4];
    for(int j = 0; j < 4; j++){
      int d1 = wall_dist[j];
      int d2 = wall_dist[(j+1)%4];
      // ????????????????§????
      int d = min(d1,d2);
      const int y = YS[i] + dy[j] * d;
      const int x = XS[i] + dx[j] * d;
      stripex[j] = x;
      stripey[j] = y;
    }

    // ?????¨???, ???????????????????????§?¨??????????????????§, ??????????????¨??????
    int usex[2], usey[2];
    
    // ????????§????????????????¨????????????????
    if(AS[i]=='W'){
      usex[0] = stripex[3], usey[0] = stripey[3];
      usex[1] = stripex[0], usey[1] = stripey[0];
    }
    else if(AS[i]=='E'){
      usex[0] = stripex[1], usey[0] = stripey[1];
      usex[1] = stripex[2], usey[1] = stripey[2];
    }
    else if(AS[i]=='N'){
      usex[0] = stripex[0], usey[0] = stripey[0];
      usex[1] = stripex[1], usey[1] = stripey[1];
    }
    else if(AS[i]=='S'){
      usex[0] = stripex[2], usey[0] = stripey[2];
      usex[1] = stripex[3], usey[1] = stripey[3];
    }

    // ??§?¨?????????¢???????????????
    int dists[2];
    for(int j = 0; j < 2; j++){
      int x = usex[j];
      int y = usey[j];
      if(x == 0)dists[j] = y;
      else if(y == D)dists[j] = x + D;
      else if(x == W)dists[j] = W + D + (D - y);
      else dists[j] = W + D + D + (W - x);
      if(dists[j] == 2*(W+D)){
        dists[j] = 0;
      }
    }
    if(dists[0] > dists[1]){
      dists[1] += 2*(W + D);
    }
    // ?????¢????????\
    poses.push_back(make_pair(dists[0], dists[1]));
  }

  // vector???????????????2??????????????????
  for(int i=0;i<N;i++){
    // ??????????????????+2*(W+D)???????????????push_back
    pii pd = poses[i];
    pd.first += 2*(W+D);
    pd.second += 2*(W+D);
    poses.push_back(pd);
  }
  sort(poses.begin(), poses.end());
  
  int min_ans = 1<<29;
  // ?????¨?????£??????, ??????????§???°???????±???????, ????????????n?????????????????°????¨??????????
  for(int start = 0; start < N; start++){
      memset(used,0,sizeof(used));
      vector<tpl> vec;
      for(int i=0;i<N;i++){
        pii t = poses[start + i];
        vec.push_back(make_tuple(t.first, 0, i));
        vec.push_back(make_tuple(t.second, 1, i));
      }
      // start??????????????????end????????£????????????????´???????????????????
      queue<int> q;
      // ?????¢??§?????????
      sort(vec.begin(), vec.end());
      
      int vec_idx = 0;
      int ans = 0;
      // ???????????¢?????¨??????????????????????????????
      while((int)vec.size() != vec_idx){
          // ???????????¢??§????´??????????????????????
          int d = get<0>(vec[vec_idx]);
          vector<int> vs[2];
          while((int)vec.size()!=vec_idx && (get<0>(vec[vec_idx]) == d)){
            vs[get<1>(vec[vec_idx])].push_back(get<2>(vec[vec_idx]));
            vec_idx++;
          }
          
          // start???????´???????????????????
          // start???????´????, queue????????????
          for(int i=0;i<(int)vs[0].size();i++){
              int idx = vs[0][i];
              q.push(idx);
          }
          
          // end???????´????, ?????§???????????????????????°continue
          for(int i=0;i<(int)vs[1].size();i++){
              int idx = vs[1][i];
              if(used[idx])continue;
              else{
                  // ?????????????????£????????????????????§start???????´?????§£???????????????
                  // ????????????end????§£?????????????????§??????????????????
                  ans++;
                  while(q.size()){
                      const int a = q.front(); q.pop();
                      used[a] = true;
                  }
                  break;
              }
          }
      }
      min_ans = min(min_ans, ans);
  }

  cout<<min_ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3240