#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int maxn = 100010;
int now, n;
struct node {
  int peo;
  double dis;
} ct[1010];
bool check(double d) {
  int sum = 0, i;
  for (i = 0; i < n; i++)
    if (ct[i].dis <= d) sum += ct[i].peo;
  if (sum + now >= 1000000)
    return true;
  else
    return false;
}
int main() {
  int i, sum, x, y;
  double hi, mid, low, ans;
  while (~scanf("%d%d", &n, &now)) {
    ans = INF;
    low = hi = sum = 0;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &x, &y, &ct[i].peo);
      sum += ct[i].peo;
      ct[i].dis = x * x + y * y;
      hi = max(hi, ct[i].dis);
    }
    if (sum + now < 1000000) {
      printf("-1\n");
      continue;
    }
    for (i = 0; i < n; i++) {
      mid = ct[i].dis;
      if (check(mid)) ans = min(ans, mid);
    }
    printf("%.8lf\n", sqrt(ans));
  }
  return 0;
}
