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