#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  multiset<pair<long long, long long>> s;
  vector<tuple<long long, long long, long long>> v;
  long long i;
  for (i = 0; i < n; i++) {
    long long a, b, p;
    cin >> a >> b >> p;
    s.insert({(a * a + b * b), i});
    v.push_back(make_tuple(a, b, p));
  }
  if (k >= 1e6) {
    cout << 0.00000000 << "\n";
    return 0;
  }
  long long f = -1;
  double ans;
  for (pair<long long, long long> x : s) {
    pair<long long, long long> pp = x;
    long long y = pp.second;
    k += get<2>(v[y]);
    f++;
    if (k >= 1e6) {
      double aa = get<0>(v[y]);
      double bb = get<1>(v[y]);
      ans = sqrt(aa * aa + bb * bb);
      break;
    }
  }
  if (k < 1e6) {
    cout << "-1\n";
    return 0;
  }
  std::cout << std::fixed;
  std::cout << std::setprecision(10);
  cout << ans << "\n";
}
