#include <bits/stdc++.h>
int main(void) {
  int n, pop;
  std::vector<std::pair<double, int> > cities;
  std::cin >> n >> pop;
  for (int i = 0; i < n; i++) {
    int x, y, p;
    std::cin >> x >> y >> p;
    double r = sqrt(x * x + y * y);
    std::pair<double, int> city;
    city = std::make_pair(r, p);
    cities.push_back(city);
  }
  std::sort(cities.begin(), cities.end());
  double minR = 0;
  for (int i = 0; i < n; i++) {
    if (pop < 1000000) {
      minR = cities[i].first;
      pop += cities[i].second;
    }
  }
  if (pop < 1000000)
    std::cout << -1 << std::endl;
  else
    std::cout << std::setprecision(8) << minR << std::endl;
}
