#include <bits/stdc++.h>
using namespace std;
typedef struct CT {
  int x, y, p;
  double d;
} ct;
bool acompare(ct lhs, ct rhs) { return lhs.d < rhs.d; }
double dist(double x, double y) { return sqrt(x * x + y * y); }
int main() {
  ct a[1005];
  int n, i, sum, p1;
  double r = 0;
  scanf("%d%d", &n, &p1);
  sum = 1000000;
  sum -= p1;
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &a[i].x, &a[i].y, &a[i].p);
    a[i].d = dist(a[i].x, a[i].y);
    if (sum > 0) sum -= a[i].p;
  }
  if (sum > 0)
    printf("-1");
  else {
    sort(a, a + n, acompare);
    sum = 1000000 - p1;
    for (i = 0; i < n && sum > 0; i++) {
      r = a[i].d;
      sum -= a[i].p;
    }
    printf("%.7f", r);
  }
  return 0;
}
