#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  double population;
  cin >> n >> population;
  double x, y, r;
  pair<double, double> All[n];
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    All[i].first = sqrt(pow(x, 2) + pow(y, 2));
    cin >> All[i].second;
  }
  sort(All, All + n);
  int i;
  for (i = 0; i < n; i++) {
    population += All[i].second;
    if (population >= 1000000) break;
  }
  if (i == n)
    cout << -1;
  else
    cout << setprecision(12) << All[i].first;
}
