#include <bits/stdc++.h>
using namespace std;
struct my {
  long double radius;
  int people;
};
bool operator<(my ob1, my ob2) { return ob1.radius < ob2.radius; }
int main() {
  cout.precision(15);
  int n, s, i;
  cin >> n >> s;
  if (s >= 1000000) {
    cout << 0 << endl;
    return 0;
  }
  my ob[n];
  for (i = 0; i < n; i++) {
    int x, y, t;
    long double r;
    cin >> x >> y >> t;
    r = sqrt(x * x + y * y);
    ob[i].radius = r;
    ob[i].people = t;
  }
  sort(ob, ob + i);
  long double r;
  for (i = 0; i < n; i++) {
    s += ob[i].people;
    r = ob[i].radius;
    if (s >= 1000000) {
      cout << r << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
