#include<iostream> #include<vector> #include<algorithm> using namespace std; bool cmp(const pair<int, int>& a, const pair<int, int>& b) { return a.first == b.first ? a.second > b.second : a.first < b.first; } int cal(vector<pair<int, int>>& nums, int n){ sort(nums.begin(), nums.end(), cmp); vector<int> dp(n, 1); for(int i=1; i<n; i++){ for(int j=0; j<i; j++){ if(nums[i].second >= nums[j].second){ dp[i] = max(dp[i], dp[j]+1); } } } int res = 1; for(int i=0; i<n; i++){ res = max(res, dp[i]); } return res; } int main(){ int n; while(cin >> n){ vector<pair<int,int>> nums; int index, weight, height; for(int i=0; i<n; i++){ cin >> index >> weight >> height; nums.push_back({weight, height}); } cout << cal(nums, n) << endl; } return 0; }