#include <bits/stdc++.h>
int xx[1000], yy[1000], kk[1000];
int dist2(int x, int y) { return (x * x) + (y * y); }
int compare(const void *a, const void *b) {
  int i = *(int *)a;
  int j = *(int *)b;
  return dist2(xx[i], yy[i]) - dist2(xx[j], yy[j]);
}
int main() {
  static int ii[1000];
  int n, s, i, sum, max;
  scanf("%d%d", &n, &s);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &xx[i], &yy[i], &kk[i]);
    ii[i] = i;
  }
  qsort(ii, n, sizeof *ii, compare);
  sum = s;
  max = 0;
  for (i = 0; i < n; i++) {
    sum += kk[ii[i]];
    if (sum >= 1000000) {
      printf("%.7f\n", hypot(xx[ii[i]], yy[ii[i]]));
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}
