#include <bits/stdc++.h>
using namespace std;
struct c {
  int x;
  int y;
  int k;
};
bool compare(c cod1, c cod2) {
  return (cod1.x * cod1.x + cod1.y * cod1.y) <
         (cod2.x * cod2.x + cod2.y * cod2.y);
}
int main() {
  int n, s;
  double r;
  int M = 1000000;
  cin >> n >> s;
  struct c cod[n];
  for (int i = 0; i < n; i++) {
    cin >> cod[i].x >> cod[i].y >> cod[i].k;
  }
  sort(cod, cod + n, compare);
  if (s >= M) {
    cout << 0;
  } else {
    for (int i = 0; i < n; i++) {
      s += cod[i].k;
      if (s >= M) {
        r = sqrt(cod[i].x * cod[i].x + cod[i].y * cod[i].y);
        break;
      }
    }
    if (s >= M) {
      cout << fixed << setprecision(6) << r;
    } else {
      cout << -1;
    }
  }
  return 0;
}
