#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<double, int>& a, pair<double, int>& b) {
  if (a.first > b.first)
    return false;
  else if (a.first == b.first) {
    if (a.second < b.second) return false;
  }
  return true;
}
int main() {
  int n, s;
  cin >> n >> s;
  vector<pair<double, int>> p;
  for (int i = 0; i < n; i++) {
    double x, y;
    int k;
    cin >> x >> y >> k;
    x = sqrt((x * x) + (y * y));
    p.push_back(make_pair(x, k));
  }
  sort(p.begin(), p.end(), cmp);
  double ans = -1;
  for (int i = 0; i < n; i++) {
    s += p[i].second;
    if (s >= 1000000) {
      ans = p[i].first;
      break;
    }
  }
  if (ans == -1)
    cout << -1 << endl;
  else
    cout << fixed << setprecision(6) << ans << endl;
}
