#include <bits/stdc++.h>
using namespace std;
int n, s, total, x, y, d, curr;
deque<pair<pair<int, int>, int> > points;
double radius = 0.0;
double dist(pair<int, int> p1, pair<int, int> p2) {
  return hypot(p1.first - p2.first, p1.second - p2.second);
}
bool comp(pair<pair<int, int>, int> p1, pair<pair<int, int>, int> p2) {
  return dist(pair<int, int>(0, 0), p1.first) <
         dist(pair<int, int>(0, 0), p2.first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> s;
  total = s;
  curr = s;
  if (n >= 1000000) {
    cout << 0 << "\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> d;
    total += d;
    points.push_back(pair<pair<int, int>, int>(pair<int, int>(x, y), d));
  }
  if (total < 1000000) {
    cout << "-1\n";
    return 0;
  }
  sort(points.begin(), points.end(), comp);
  do {
    pair<pair<int, int>, int> f = points.front();
    points.pop_front();
    radius = dist(pair<int, int>(0, 0), f.first);
    curr += f.second;
  } while (curr < 1000000);
  cout << setprecision(7) << fixed;
  cout << radius << "\n";
}
