func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MAXN = 5e5 + 5;   struct Node {     long long t, h, m;   } a[MAXN];   bool cmp(Node x, Node y) { return x.m > y.m; }   long long n, x;   long long vis[MAXN];   long long solve(long long now) {     memset(vis, 0, sizeof(vis));     long long ans = 0;     long long h = x;     while (1) {       long long f = 0;       for (long long i = 1; i <= n; i++) {         if (vis[i] == 0 && now != a[i].t && h >= a[i].h) {           f = 1;           now = 1 - now;           vis[i] = 1;           ans++;           h += a[i].m;           break;         }       }       if (f == 0) {         break;       }     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> x;     for (long long i = 1; i <= n; i++) {       cin >> a[i].t >> a[i].h >> a[i].m;     }     sort(a + 1, a + n + 1, cmp);     long long ans = max(solve(1), solve(0));     cout << ans << endl;   }   