#include <bits/stdc++.h>

using namespace std;

const int64_t INF = INT64_C(1) << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int64_t X;
  cin >> X;
  vector<int64_t> A(N);
  for (auto &&e : A) {
    cin >> e;
  }
  int64_t res = INF;
  for (int k = 1; k < N + 1; k++) {
    vector<vector<int64_t>> dp(k + 1, vector<int64_t>(k, -INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
      for (int j = k; j > 0; j--) {
        for (int r = 0; r < k; r++) {
          if (dp[j - 1][r] < 0) continue;
          dp[j][(r + A[i]) % k] = max(dp[j][(r + A[i]) % k], dp[j - 1][r] + A[i]);
        }
      }
    }
    if (dp[k][X % k] > 0) res = min(res, (X - dp[k][X % k]) / k);
  }
  cout << res << '\n';
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep2(i, j, n) for(int i=j;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

map<int, ll> table;
int main(){
    int N;
    cin >> N;
    ll C;
    cin >> C;
    rep(i, N){
        int a, b, e;
        cin >> a >> b >> e;
        table[a-1] += e;
        table[b] -= e;
    }
    vector<pair<int, ll>> table2;
    for(pair<int, ll> p : table){
        table2.pb(p);
    }
    sort(all(table2));
    ll rui[table2.size()+1];
    ll sum = 0;
    rui[0] = 0;
    rep(i, table2.size()){
        rui[i+1] = rui[i] + table2[i].second;
        if(i>0 && rui[i]>C){
            sum += (table2[i].first - table2[i-1].first)*C;
        } else if(i>0) {
            sum += (table2[i].first - table2[i-1].first)*rui[i];
        }
    }
   
    cout << sum << endl;
}
