#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N, P, Arr[10000][3], i;
  double rad[10000], pop[1000];
  cin >> N >> P;
  int s = 0, e = N - 1, mid;
  for (int i = 0; i < N; i++) {
    cin >> Arr[i][0] >> Arr[i][1] >> pop[i];
  }
  for (int i = 0; i < N; i++) {
    rad[i] = sqrt((Arr[i][0] * Arr[i][0]) + (Arr[i][1] * Arr[i][1]));
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (rad[i] > rad[j]) {
        swap(rad[i], rad[j]);
        swap(pop[i], pop[j]);
      }
    }
  }
  for (int i = 1; i < N; i++) {
    pop[i] += pop[i - 1];
  }
  while (s <= e) {
    mid = (e + s) / 2;
    if (P + pop[mid] < 1000000) {
      s = mid + 1;
    } else {
      e = mid - 1;
    }
  }
  if (P + pop[s] >= 1000000) {
    cout << fixed << setprecision(8) << rad[s] << endl;
  } else {
    cout << "-1" << endl;
  }
  return 0;
}
