#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, double> a, pair<int, double> b) {
  return a.second < b.second;
}
void solve() {
  int n, s;
  cin >> n >> s;
  int k[n + 1];
  double x[n + 1], y[n + 1], sum = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> y[i] >> k[i];
    sum += k[i];
  }
  if (s + sum < 1000000) {
    cout << -1;
    return;
  }
  if (s == 1000000) {
    cout << 0;
    return;
  }
  int req = 1000000 - s;
  vector<pair<int, double>> dist(n + 1);
  dist[0].first = -1;
  dist[0].second = 0;
  for (int i = 1; i <= n; ++i) {
    dist[i].first = k[i];
    dist[i].second = sqrt(x[i] * x[i] + y[i] * y[i]);
  }
  sort(dist.begin(), dist.end(), comp);
  int pref[n + 1];
  pref[0] = 0;
  for (int i = 1; i <= n; ++i) pref[i] = pref[i - 1] + dist[i].first;
  double res = 0;
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r) / 2;
    if (pref[mid] >= req && pref[mid - 1] < req) {
      res = dist[mid].second;
      break;
    }
    if (pref[mid] >= req) {
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  if (!res) {
    if (pref[l] >= req) {
      res = dist[l].second;
    } else
      res = dist[r].second;
  }
  cout << fixed << setprecision(7) << res;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
