#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main() {
  int n, p, a = 0, x, y, z;
  cin >> n >> p;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> z;
    v.push_back(make_pair(x * x + y * y, z));
    a += z;
  }
  if ((p + a) < 1000000) {
    cout << -1;
    return 0;
  }
  sort(v.begin(), v.end());
  int r = 0, c = 0;
  for (int i = 0; i < n; i++) {
    c += v[i].second;
    if ((c + p) >= 1000000) {
      r = v[i].first;
      break;
    }
  }
  double ans = sqrt(1.0 * r);
  printf("%.6f", ans);
}
