#include <bits/stdc++.h>
using namespace std;
struct point {
  int x;
  int y;
  int k;
  double r;
};
bool cmp(const point &a, const point &b) { return a.r < b.r; }
int main() {
  int n, s, sum;
  cin >> n >> s;
  point *a = new point[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].x >> a[i].y >> a[i].k;
  }
  for (int i = 0; i < n; i++) {
    a[i].r = sqrt(a[i].x * a[i].x + a[i].y * a[i].y);
  }
  sort(a, a + n, cmp);
  bool flag = false;
  sum = s;
  for (int i = 0; i < n; i++) {
    if ((sum = sum + a[i].k) >= 1000000) {
      flag = true;
      printf("%.7lf\n", a[i].r);
      break;
    }
  }
  if (!flag) {
    cout << "-1" << endl;
  }
  return 0;
}
