#include <bits/stdc++.h>
using namespace std;
int n, s, cum[1001], x, y, p;
vector<pair<double, int> > vec;
double rad(int x, int y) {
  double r = (x * x) + (y * y);
  r = sqrt(r);
  return r;
}
int binary(int low, int high) {
  int l = low, h = high, mid;
  while (l <= h) {
    mid = (l + h) / 2;
    if ((cum[mid] + s) >= (1e6)) {
      h = mid - 1;
    } else
      l = mid + 1;
  }
  if (cum[h + 1] + s >= (1e6)) return h + 1;
  return (-1);
}
int main() {
  double r;
  cin >> n >> s;
  for (int j = 0; j < n; j++) {
    cin >> x >> y >> p;
    r = rad(x, y);
    vec.push_back(make_pair(r, p));
  }
  sort(vec.begin(), vec.end());
  for (int j = 0; j < n; j++) {
    if (j == 0) {
      cum[j] = vec[j].second;
      continue;
    }
    cum[j] = cum[j - 1] + vec[j].second;
  }
  int idx = binary(0, n - 1);
  if (idx == -1)
    cout << idx << endl;
  else
    cout << setprecision(8) << fixed << vec[idx].first << endl;
  return 0;
}
