#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  double x, y, r[n], pop[n], s1 = s;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> pop[i];
    r[i] = sqrt((x * x) + (y * y));
    s1 += pop[i];
  }
  if (s1 < 1000000)
    cout << -1;
  else {
    double start = 0, last = 100000, mid;
    while (last - start > 0.00000001) {
      mid = (start + last) / 2;
      s1 = s;
      for (int i = 0; i < n; i++) {
        if (mid >= r[i]) s1 += pop[i];
      }
      if (s1 >= 1000000) {
        last = mid;
      } else {
        start = mid;
      }
    }
    cout << setprecision(8) << start;
  }
  return 0;
}
