#include <bits/stdc++.h>
const int inf = 2000 * 1000 * 1000;
const double eps = 1e-7;
using namespace std;
int n, s, second;
int x[100005], y[100005], k[100005];
bool check(double r) {
  second = s;
  for (int i = 1; i <= n; i++)
    if (x[i] * x[i] + y[i] * y[i] <= r * r) second += k[i];
  return (second >= 1000000);
}
int main() {
  scanf("%d %d\n", &n, &s);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d\n", &x[i], &y[i], &k[i]);
    second += k[i];
  }
  if (s + second < 1000000) {
    printf("-1\n");
    return 0;
  }
  double l = 0, r = 15000;
  while (r - l >= eps) {
    double m = (l + r) / 2;
    if (check(m))
      r = m;
    else
      l = m;
  }
  printf("%.7lf\n", r);
  return 0;
}
