#include <bits/stdc++.h>
long long a[10000000];
double rr[10000000];
using namespace std;
int main() {
  long long n, s, k;
  double x, y, r;
  long long sum = 0;
  cin >> n >> s;
  sum = s;
  for (int c = 0; c < n; c++) {
    cin >> x >> y;
    r = sqrt((x * x) + (y * y));
    rr[(int)(r * 100)] = r;
    cin >> k;
    sum += k;
    a[(int)(r * 100)] = a[(int)(r * 100)] + k;
  }
  if (sum < 1000000)
    cout << -1;
  else {
    sum = s;
    for (int c = 0;; c++) {
      sum += a[c];
      if (sum >= 1000000) {
        cout << fixed << setprecision(10) << rr[c];
        break;
      }
    }
  }
}
