#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, k, i, l;
pair<double, double> b[100005];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y >> k;
    b[i].second = k;
    b[i].first = sqrt(x * x + y * y);
    l += k;
  }
  if (m + l < 1000000) {
    cout << -1;
    return 0;
  }
  sort(b + 1, b + 1 + n);
  for (i = 1; i <= n; i++)
    if (m + b[i].second >= 1000000) {
      cout << setprecision(8) << b[i].first;
      return 0;
    } else
      m += b[i].second;
}
