#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s;
  cin >> n >> s;
  int d = 1000000 - s;
  int x, y, num;
  long long int sum = 0;
  vector<pair<long long int, long long int>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> num;
    long long int dis = (x * x) + (y * y);
    sum += num;
    v[i] = make_pair(dis, num);
  }
  if (sum >= d) {
    sort(v.begin(), v.end());
    double ans;
    for (int i = 0; i < n; i++) {
      d = d - v[i].second;
      ans = sqrt(v[i].first);
      if (d <= 0) break;
    }
    std::cout << std::fixed;
    std::cout << std::setprecision(6);
    std::cout << ans;
  } else {
    cout << -1 << "\n";
  }
}
