#include <bits/stdc++.h>
using namespace std;
struct city {
  int x, y, p;
  double dis;
} t[1010];
int cmp(city a, city b) { return a.dis < b.dis; }
int main() {
  int s, n, i;
  while (scanf("%d%d", &n, &s) > 0) {
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &t[i].x, &t[i].y, &t[i].p);
      t[i].dis = sqrt(t[i].x * t[i].x + t[i].y * t[i].y);
    }
    sort(t, t + n, cmp);
    double ans;
    for (i = 0; i < n; i++) {
      s += t[i].p;
      if (s >= 1e6) {
        ans = t[i].dis;
        break;
      }
    }
    if (i == n) {
      printf("-1\n");
      continue;
    }
    printf("%lf\n", ans);
  }
  return 0;
}
