#include <bits/stdc++.h>
using namespace std;
typedef struct {
  double d;
  int num;
} node;
node no[1005];
int cmp(node a, node b) { return a.d < b.d; }
double dis(int x, int y) { return sqrt(x * x + y * y); }
int main() {
  int n, s;
  scanf("%d%d", &n, &s);
  for (int i = 0; i < n; ++i) {
    double x, y;
    scanf("%lf%lf%d", &x, &y, &no[i].num);
    no[i].d = dis(x, y);
  }
  sort(no, no + n, cmp);
  int ans;
  for (ans = 0; ans < n; ++ans) {
    if (s < 1000000) {
      s += no[ans].num;
      if (s >= 1000000) {
        printf("%.7f\n", no[ans].d);
        break;
      }
    }
  }
  if (ans == n) printf("-1\n");
  return 0;
}
