1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,x,y) for(int i = (int)(x); i < (int)(y); ++i)
#define FORE(i,x,y) for(int i = (int)(x); i <= (int)(y); ++i)
#define FORD(i,x,y) for(int i = (int)(x); i >= (int)(y); --i)
#define PB push_back
typedef long long ll;
typedef pair<int,int> pii;
const int MLNX = 1e6+7;
int n;
int a[2*MLNX][2];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    FOR(i,0,n) {
        int r,w,t;
        cin>>r>>w>>t;
        if (r == 1) {
            ++a[MLNX+w-t][0];
        } else {
            ++a[MLNX+w-t][1];
        }
    }
    int ans = 0;
    FORD(i,2*MLNX-1,0) {
        ans += max(a[i][0],a[i][1]);
    }
    cout<<n-ans<<"\n";
    return 0;
}
/*
6
1 5 2
2 3 0
2 3 6
2 100 97
2 101 98
1 7 4

4
1 1000000 2
2  999998 0
1 2 1000000
2 0  999998
*/