#include <bits/stdc++.h>
double arr[1005][4];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int i;
  long long population = k;
  double maxRadius = -1, minRadius = 1e6;
  for (i = 0; i < n; i++) {
    scanf("%lf%lf%lf", &arr[i][0], &arr[i][1], &arr[i][2]);
    population += arr[i][2];
    arr[i][3] = sqrt((arr[i][0] * arr[i][0]) + (arr[i][1] * arr[i][1]));
  }
  if (population < 1000000)
    printf("-1\n");
  else {
    int i, j;
    for (i = 0; i < n; i++) {
      for (j = 0; j < n - 1; j++) {
        if (arr[j][3] > arr[j + 1][3]) {
          double temp = arr[j][3];
          arr[j][3] = arr[j + 1][3];
          arr[j + 1][3] = temp;
          temp = arr[j][0];
          arr[j][0] = arr[j + 1][0];
          arr[j + 1][0] = temp;
          temp = arr[j][1];
          arr[j][1] = arr[j + 1][1];
          arr[j + 1][1] = temp;
          temp = arr[j][2];
          arr[j][2] = arr[j + 1][2];
          arr[j + 1][2] = temp;
        }
      }
    }
    double radius = 0;
    population = k;
    for (i = 0; i < n; i++) {
      if (population >= 1000000)
        break;
      else {
        radius = arr[i][3];
        population += arr[i][2];
        for (j = i + 1; arr[j][3] == arr[i][3] && population < 1000000; j++) {
          population += arr[j][2];
        }
        i = j - 1;
      }
    }
    printf("%lf\n", radius);
  }
  return 0;
}
