#include <bits/stdc++.h>
using namespace std;
inline double way(int x, int y) { return ((x * x) + (y * y)); }
int main() {
  int n, s;
  cin >> n >> s;
  int x[n], y[n], k[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> k[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (way(x[i], y[i]) > way(x[j], y[j])) {
        swap(x[i], x[j]);
        swap(y[i], y[j]);
        swap(k[i], k[j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    s += k[i];
    if (s >= 1000000) {
      cout << fixed;
      cout << setprecision(7) << sqrt(way(x[i], y[i])) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
