#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r = 0, k, s;
  double x, y;
  vector<pair<double, int> > V;
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y >> k;
    V.push_back(make_pair(sqrt((x * x) + (y * y)), k));
  }
  sort(V.begin(), V.end());
  while (r <= V.size() - 1 && s < 1e6) {
    s += V[r++].second;
  }
  if (s < 1e6)
    cout << "-1\n";
  else
    cout << fixed << setprecision(7) << V[r - 1].first << "\n";
}
