#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
int geti() {
  int y = 0, s = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') s = -1, c = getchar();
  while (isdigit(c)) y = y * 10 + (c - '0'), c = getchar();
  return s * y;
}
double dist(pair<double, double> f, pair<double, double> s) {
  double a = f.first - s.first;
  double b = f.second - s.second;
  return sqrt(a * a + b * b);
}
int main() {
  int n = geti(), s = geti();
  vector<pair<double, int> > v(n);
  for (int a = 0; a < n; a++) {
    int x = geti(), y = geti(), k = geti();
    double c = dist(make_pair(0, 0), make_pair(x, y));
    v[a] = make_pair(c, -k);
  }
  sort(v.begin(), v.end());
  double p = s, r = 0;
  for (int a = 0; a < n; a++) {
    p -= v[a].second;
    r = v[a].first;
    if (p >= 1000000) {
      printf("%.7lf\n", r);
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
