#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, s, x, y, p;
  cin >> n >> s;
  vector<pair<long double, int>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> p;
    v[i].first = sqrtl(x * x + y * y);
    v[i].second = p;
  }
  sort(v.begin(), v.end());
  int c = s;
  for (int i = 0; i < n; i++) {
    c += v[i].second;
    if (c >= 1000000) {
      cout << setprecision(12) << v[i].first;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
