#include <bits/stdc++.h>
using namespace std;
long long int dist(pair<long long int, long long int> a,
                   pair<long long int, long long int> b) {
  long long int dx = (a.first - b.first);
  long long int dy = (a.second - b.second);
  return dx * dx + dy * dy;
}
bool cmp(pair<long long int, long long int> a,
         pair<long long int, long long int> b) {
  if (a.second < b.second) return true;
  if (a.second == b.second) return a.first > b.first;
  return false;
}
int main() {
  int n, s;
  cin >> n;
  cin >> s;
  vector<pair<long long int, long long int> > vc(n);
  pair<long long int, long long int> po =
      pair<long long int, long long int>(0, 0);
  for (int i = 0; i < n; i++) {
    int pop;
    pair<long long int, long long int> p;
    cin >> p.first >> p.second >> pop;
    vc[i] = pair<long long int, long long int>(pop, dist(p, po));
  }
  sort(vc.begin(), vc.end(), cmp);
  long long int curr_pop = s;
  long long int curr_radius = 0;
  int k = 0;
  while (k < vc.size() && curr_pop < 1000000) {
    curr_pop += vc[k].first;
    curr_radius = max(curr_radius, vc[k].second);
    k++;
  }
  if (curr_pop >= 1000000) {
    double radious = sqrt((double)curr_radius);
    printf("%lf\n", radious);
  } else {
    cout << -1 << endl;
  }
}
