#include <bits/stdc++.h>
using namespace std;
int n, s;
double x[10005], y[10005];
int k[10005];
int main() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> k[i];
  double R = 2000000000;
  int flag = false;
  for (int i = 0; i < n; i++) {
    int p = 0;
    for (int j = 0; j < n; j++) {
      if (sqrt(x[j] * x[j] + y[j] * y[j]) <= sqrt(x[i] * x[i] + y[i] * y[i])) {
        p += k[j];
      }
    }
    if (p + s >= 1e6) {
      R = min(R, sqrt(x[i] * x[i] + y[i] * y[i]));
      flag = 1;
    }
  }
  if (s >= 1e6) {
    printf("%.7lf", 0);
  } else {
    if (flag) {
      printf("%.7lf", R);
    } else {
      puts("-1");
    }
  }
  return 0;
}
