private void go(){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		x = in.nextInt();
		int xCopy = x;
		
		ArrayList<Candy> t0 = new ArrayList<Candy>();
		ArrayList<Candy> t1 = new ArrayList<Candy>();
		
		ArrayList<Candy> t0Copy = new ArrayList<Candy>();
		ArrayList<Candy> t1Copy = new ArrayList<Candy>();
		
		for(int i=0;i<n;i++){
			int t = in.nextInt();
			int h = in.nextInt();
			int m = in.nextInt();
			if(t == 0){
				t0.add(new Candy(h, m));
				t0Copy.add(new Candy(h, m));
			}else{
				t1.add(new Candy(h, m));
				t1Copy.add(new Candy(h, m));
			}
		}
		
		Collections.sort(t0);
		Collections.sort(t1);
		Collections.sort(t0Copy);
		Collections.sort(t1Copy);
		
		int result1 = startWith(0, t0, t1);
		x = xCopy;
		int result2 = startWith(1, t0Copy, t1Copy);
		
//		System.out.println(result1+" "+result2);
		
		System.out.println(result1>result2?result1:result2);
	}