#include <bits/stdc++.h>
using namespace std;
long long int count(
    vector<pair<pair<long long int, long long int>, long long int>>& A,
    long long int n, long double r) {
  long long int c = 0;
  for (long long int i = 0; i < n; i++) {
    if (sqrt(A[i].first.first * A[i].first.first +
             A[i].first.second * A[i].first.second) <= r)
      c += A[i].second;
  }
  return c;
}
int main() {
  long long int n, p;
  cin >> n >> p;
  vector<pair<pair<long long int, long long int>, long long int>> A(n);
  for (long long int i = 0; i < n; i++) {
    long long int x, y, p1;
    cin >> x >> y >> p1;
    A[i].first.first = x;
    A[i].first.second = y;
    A[i].second = p1;
  }
  long double l = 0, r = 100000, ans = 1e18;
  long long int t = 0;
  while (t < 100) {
    long double m = (l + r) / 2;
    long long int c = count(A, n, m);
    if (c + p >= 1e6) {
      ans = min(ans, m);
      r = m;
    } else {
      l = m;
    }
    t++;
  }
  if (ans >= 1e18)
    cout << -1 << endl;
  else
    printf("%.10Lf\n", ans);
}
