#include <bits/stdc++.h>
#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ull const mod = 1000000007;
ll const need = 1000000;
ld dist(ll x, ll y) { return sqrtl((ld)x * x + y * y); }
int main() {
  cout << setprecision(8) << fixed;
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  ll n, k;
  cin >> n >> k;
  vector<pair<ld, ll>> pre(n);
  for (int i = 0; i < n; i++) {
    ll x, y, k1;
    cin >> x >> y >> k1;
    pre[i] = {dist(x, y), k1};
  }
  if (k >= need) {
    cout << (ld)0 << '\n';
    return 0;
  }
  sort(pre.begin(), pre.end());
  pre.front().second += k;
  for (int i = 1; i < pre.size(); i++) pre[i].second += pre[i - 1].second;
  for (int i = 0; i < pre.size(); i++) {
    if (pre[i].second >= need) {
      cout << pre[i].first << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}
