#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, t;
  vector<pair<double, int> > v;
  cin >> n >> t;
  int a;
  double x, y;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y >> a;
    v.push_back({sqrt((x * x) + (y * y)), a});
  }
  int h = 0;
  sort(v.begin(), v.end());
  for (; h < n; ++h) {
    t += v[h].second;
    if (t >= 1000000) {
      cout << fixed << setprecision(7) << v[h].first << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}
