#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  multimap<float, int> mp;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x, y, k;
    cin >> x >> y >> k;
    sum += k;
    float dist = sqrt(x * x + y * y);
    mp.insert({dist, k});
  }
  auto it = mp.begin();
  while (1) {
    if (s >= 1000000) break;
    int pop = it->second;
    s += pop;
    it++;
    if (it == mp.end()) break;
  }
  if (s < 1000000)
    cout << "-1";
  else if (it == mp.begin())
    cout << "0";
  else {
    it--;
    float radius = it->first;
    cout << fixed << setprecision(9) << radius;
  }
  return 0;
}
