#include <bits/stdc++.h>
using namespace std;
int main() {
  double x, y, r, res;
  map<double, long int> m1;
  map<double, long int>::iterator it;
  long int i, n, s, p;
  scanf("%ld %ld", &n, &s);
  for (i = 0; i < n; i++) {
    scanf("%lf %lf %ld", &x, &y, &p);
    r = sqrt(x * x + y * y);
    m1[r] += p;
  }
  int flag = 0;
  for (it = m1.begin(); it != m1.end(); ++it) {
    s += it->second;
    if (s >= 1000000) {
      flag = 1;
      res = it->first;
      break;
    }
  }
  if (flag == 0) {
    printf("-1\n");
  } else {
    printf("%.7lf\n", res);
  }
  return 0;
}
