#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, total;
  cin >> n >> total;
  vector<pair<double, int> > v1;
  for (int i = 0; i < n; i++) {
    double a, b;
    cin >> a >> b;
    int y;
    cin >> y;
    double x = a * a + b * b;
    x = (double)sqrt(x);
    v1.push_back(make_pair(x, y));
  }
  sort(v1.begin(), v1.end());
  bool flag = false;
  double area = 0;
  for (int i = 0; i < n; i++) {
    if (total >= 1000000) {
      flag = true;
      break;
    }
    total = total + v1[i].second;
    area = v1[i].first;
    if (total >= 1000000) {
      flag = true;
      break;
    }
  }
  if (flag == true)
    printf("%.10f", area);
  else
    cout << "-1";
}
