#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, s, c;
  long double x, y;
  cin >> n >> s;
  long double arr[2][n];
  for (long long i = 0; i < n; i++) {
    cin >> x >> y >> c;
    arr[0][i] = sqrt(powl(x, 2) + powl(y, 2));
    arr[1][i] = c;
  }
  for (long long i = 0; i < n; i++)
    for (long long h = 0; h < n - 1; h++) {
      if (arr[0][h] > arr[0][h + 1]) {
        swap(arr[0][h], arr[0][h + 1]);
        swap(arr[1][h], arr[1][h + 1]);
      }
    }
  for (long long i = 0; i < n; i++) {
    s += arr[1][i];
    if (s >= 1000000) {
      return cout << setprecision(8) << fixed << arr[0][i], 0;
    }
  }
  cout << -1;
  return 0;
}
