#include <bits/stdc++.h>
using namespace std;
const int N = 1007;
struct P {
  int x, y, k;
  int d;
  void in() {
    scanf("%d %d %d", &x, &y, &k);
    d = x * x + y * y;
  }
} p[N];
bool cmp(P a, P b) { return a.d <= b.d; }
int main() {
  int n, s, i;
  int M = 1000000;
  while (~scanf("%d %d", &n, &s)) {
    for (int i = 0; i < n; ++i) p[i].in();
    sort(p, p + n, cmp);
    int i = 0;
    while (s < M && i < n) {
      s += p[i].k;
      i++;
    }
    if ((i == n) && (s < M))
      puts("-1");
    else
      printf("%.7lf\n", sqrt(1.0 * p[i - 1].d));
  }
  return 0;
}
