#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 5;
const long long oo = 1ll << 40;
int n, s, x[MAXN], y[MAXN], k[MAXN];
bool ok(long long m) {
  long long sum = s;
  for (int i = 0; i < n; ++i) {
    if (x[i] * x[i] + y[i] * y[i] <= m) sum += k[i];
  }
  return sum >= 1e6;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(8) << fixed;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> k[i];
  long long lo = 0, hi = oo;
  while (lo < hi) {
    long long m = (lo + hi) / 2;
    if (ok(m))
      hi = m;
    else
      lo = m + 1;
  }
  if (hi == oo)
    cout << -1 << endl;
  else
    cout << sqrt(hi * 1.0) << endl;
  return 0;
}
