package javaa2019;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Scanner;
public class 轨道炮 {
static int n;
static PLAN plan[];
static long max = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
plan = new PLAN[n];
sc.nextLine();
for(int i = 0;i<plan.length;i++){
String srr[] = sc.nextLine().split(" ");
plan[i] = new PLAN(Long.parseLong(srr[0]),Long.parseLong(srr[1]),Long.parseLong(srr[2]),srr[3]);
}
Calendar st = Calendar.getInstance();
max = count();
for(int d = 0;d<50000;d++){
fly();
long dd = count();
if(dd>max)
max = dd;
}
System.out.println(max);
Calendar en = Calendar.getInstance();
// System.out.println(en.getTimeInMillis()-st.getTimeInMillis());
}
static void fly(){
for(int i = 0;i<plan.length;i++){
String fl = plan[i].drirect;
if(fl.equals("R"))
plan[i].x+=plan[i].v;
if(fl.equals("L"))
plan[i].x-=plan[i].v;
if(fl.equals("U"))
plan[i].y+=plan[i].v;
if(fl.equals("D"))
plan[i].y-=plan[i].v;
}
}
static long count(){
HashMap<Long, Long> xHashMap = new HashMap<Long, Long>();
HashMap<Long, Long> yHashMap = new HashMap<Long, Long>();
for(int i = 0;i<plan.length;i++){
long x = plan[i].x;
long y = plan[i].y;
xHashMap.put(x,xHashMap.containsKey(x)?xHashMap.get(x)+1:1);
yHashMap.put(y,yHashMap.containsKey(y)?yHashMap.get(y)+1:1);
}
long max = 0;
for(long i:xHashMap.keySet())
if(xHashMap.get(i)>max)
max = xHashMap.get(i);
for(long i:yHashMap.keySet())
if(yHashMap.get(i)>max)
max = yHashMap.get(i);
return max;
}
}
class PLAN{
long x;
long y;
long v;
String drirect;
public PLAN(Long x,Long y,long l,String di){
this.x = x;
this.y = y;
this.v = l;
this.drirect = di;
}
@Override
public String toString() {
return "PLAN [drirect=" + drirect + ", v=" + v + ", x=" + x + ", y="
+ y + "]";
}
}
//4
//0 0 1 R
//0 10 1 R
//10 10 2 D
//2 3 2 L