#include <bits/stdc++.h>
using namespace std;
typedef struct node {
  double d;
  int p;
  node(double a = 0, int b = 0) {
    d = a;
    p = b;
  }
  bool operator<(const node &th) const {
    if (th.d > d)
      return 1;
    else
      return 0;
  }
} node;
node t[1001];
int main() {
  int i, n, s;
  scanf("%d%d", &n, &s);
  for (i = 0; i < n; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    double dd = sqrt(a * a + b * b);
    t[i].d = dd;
    t[i].p = c;
  }
  sort(t, t + n);
  if (s >= 1000000)
    puts("0");
  else
    for (i = 0; i < n; i++) {
      s += t[i].p;
      if (s >= 1000000) {
        printf("%.7lf\n", t[i].d);
        break;
      }
    }
  if (s < 1000000) puts("-1");
  return 0;
}
