#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using usize = std::size_t;
using isize = std::ptrdiff_t;
using u64 = std::uint64_t;

static constexpr u64 mod = 1000000007;

template <class T> void chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
  }
}

int main() {
  usize n, cc;
  std::cin >> n >> cc;
  static constexpr usize C = 100;
  static constexpr usize A = 10000;

  std::array<std::array<isize, A + 1>, C + 1> dp;
  for (auto &v : dp) {
    std::fill(v.begin(), v.end(), std::numeric_limits<isize>::min());
  }
  dp[0][0] = 0;
  for (usize nn = 0; nn != n; ++nn) {
    usize a, b, c;
    std::cin >> a >> b >> c;
    for (usize i = C + 1; i-- != 0;) {
      for (usize j = 0; j <= A; ++j) {
        if (i >= c && j >= a) {
          chmax<isize>(dp[i][j], dp[i - c][j - a] + b);
        }
        if (i >= c && j >= b) {
          chmax<isize>(dp[i][j], dp[i - c][j - b] + a);
        }
      }
    }
  }

  usize ans = 0;
  for (usize i = 0; i <= C; ++i) {
    for (usize j = 0; j <= A; ++j) {
      if (i <= cc && dp[i][j] >= 0) {
        chmax(ans, std::min<usize>(j, dp[i][j]));
      }
    }
  }

  std::cout << ans << std::endl;

  return 0;
}
