#include <bits/stdc++.h>

using namespace std;

int N, C;
int a[101], b[101], c[101];

int dp[2][101][10101];

int main() {
  cin >> N >> C;
  for(int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];

  memset(dp, -1, sizeof(dp));
  int (*curr)[10101] = dp[0];
  int (*next)[10101] = dp[1];
  curr[0][0] = 0;
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 101; j++)
      for(int k = 0; k < 10101; k++) next[j][k] = -1;
    for(int j = C; j >= 0; j--) {
      for(int k = 10000; k >= 0; k--) {
	if(curr[j][k] == -1) continue;
	next[j][k] = curr[j][k];
	if(j+c[i] > C) continue;
	if(k+a[i] <= 10000) next[j+c[i]][k+a[i]] = max(next[j+c[i]][k+a[i]], curr[j][k]+b[i]);
	if(k+b[i] <= 10000) next[j+c[i]][k+b[i]] = max(next[j+c[i]][k+b[i]], curr[j][k]+a[i]);
      }
    }
    swap(curr, next);
  }

  /*
  for(int i = 0; i <= C; i++) {
    for(int j = 0; j < 10; j++) {
      cout << i << " " << j << " " << curr[i][j] << endl;
    }
  }
  */

  int ans = 0;
  for(int i = 0; i <= C; i++) {
    for(int j = 0; j <= 10000; j++) {
      ans = max(ans, min(j, curr[i][j]));
    }
  }
  cout << ans << endl;

  return 0;
}