#include <bits/stdc++.h>
using namespace std;
struct City {
  double dist;
  int population;
  City(double d, int p) : dist(d), population(p) {}
  bool operator<(const City& other) const { return dist < other.dist; }
};
int main(int argc, char* argv[]) {
  int n, s;
  cin >> n >> s;
  vector<City> cs;
  cs.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x, y, k;
    cin >> x >> y >> k;
    cs.push_back(City(hypot(x, y), k));
  }
  sort(cs.begin(), cs.end());
  int next_city = 0;
  while (s < 1000000 && next_city < n) {
    s += cs[next_city].population;
    next_city++;
  }
  if (s >= 1000000) {
    cout << setprecision(8) << cs[next_city - 1].dist << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
