#include <bits/stdc++.h>
using namespace std;
struct node {
  double dis;
  int peo;
} city[1002];
bool cmp(node x, node y) { return x.dis < y.dis; }
int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  int x, y, k;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &x, &y, &k);
    city[i].dis = sqrt(x * x + y * y);
    city[i].peo = k;
  }
  sort(city, city + n, cmp);
  int t = 0;
  double ans = 0;
  while (s < 1000000) {
    if (t == n) {
      ans = -1;
      break;
    }
    s += city[t].peo;
    ans = city[t].dis;
    t++;
  }
  if (ans == -1)
    printf("-1\n");
  else
    printf("%.7lf\n", ans);
  return 0;
}
