#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  vector<pair<double, int>> vec(n);
  for (int i = 0; i < n; i++) {
    double x, y, k;
    cin >> x >> y >> k;
    double len = sqrt((x * x + y * y));
    vec[i].first = len;
    vec[i].second = k;
  }
  sort(vec.begin(), vec.end());
  double maxi = 0;
  for (int i = 0; i < n; i++) {
    s += vec[i].second;
    maxi = max(maxi, vec[i].first);
    if (s >= 1000000) {
      break;
    }
  }
  if (s < 1000000) {
    cout << -1 << endl;
  } else {
    cout << fixed << setprecision(7) << maxi << endl;
  }
}
