#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  long long int s;
  cin >> n >> s;
  pair<long double, long long int> arr[n];
  for (i = 0; i < n; i++) {
    int x, y;
    long long int k;
    cin >> x >> y >> k;
    arr[i].first = sqrt(x * x + y * y);
    arr[i].second = k;
  }
  sort(arr, arr + n);
  long long int sum = s;
  long double rad = 0;
  i = 0;
  while (sum < 1000000 && i < n) {
    sum += arr[i].second;
    rad = arr[i].first;
    i++;
  }
  if (sum >= 1000000)
    cout << setprecision(8) << rad << endl;
  else
    cout << "-1 " << endl;
  return 0;
}
