#include <bits/stdc++.h>
using namespace std;
double x[10000], y[10000], q[100000];
int r[100000];
int main() {
  int i, j, n, mj, s = 0;
  double m, m1, m2, m3, c = 0;
  cin >> n >> s;
  for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
  for (i = 0; i < n; i++) {
    q[i] = sqrt((x[i] - 0) * (x[i] - 0) + (y[i] - 0) * (y[i] - 0));
  }
  for (i = 0; i < n - 1; i++) {
    for (m = 1e9, j = i; j < n; j++)
      if (q[j] < m) m = q[j], mj = j, m1 = x[j], m2 = y[j], m3 = r[j];
    q[mj] = q[i], q[i] = m, x[mj] = x[i], y[mj] = y[i], r[mj] = r[i], x[i] = m1,
    y[i] = m2, r[i] = m3;
  }
  i = 0;
  while (1) {
    s += r[i];
    c = q[i];
    i++;
    if (s >= 1000000) {
      cout << fixed << setprecision(7);
      cout << c << endl;
      return 0;
    }
    if (i >= n) break;
  }
  cout << -1 << endl;
  return 0;
}
