#include <bits/stdc++.h>
using namespace std;
int main() {
  double n, s;
  cin >> n >> s;
  double p = 10e5 - s;
  vector<pair<double, double> > v;
  for (int i = 0; i < n; i++) {
    double x, y, k;
    cin >> x >> y >> k;
    double r = sqrt((x * x) + (y * y));
    v.push_back(make_pair(r, k));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    p = p - v[i].second;
    if (p <= 0) {
      cout << setprecision(12) << v[i].first;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}
