#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double PI = atan(1.0) * 4;
const int inf = 2147483647 / 2;
const int maxn = 1000000;
template <class T>
void chmin(T &t, T first) {
  if (first < t) t = first;
}
template <class T>
void chmax(T &t, T first) {
  if (first > t) t = first;
}
template <class T>
int sgn(T first) {
  return (first > eps) - (first < -eps);
}
struct nod {
  int first, second, num;
} an[1005];
double dis(int first, int second) {
  return sqrt(0.0 + first * first + second * second);
}
bool cmp(nod a, nod b) {
  return dis(a.first, a.second) < dis(b.first, b.second);
}
int main() {
  int n, sum;
  while (cin >> n >> sum) {
    for (int i = (0); i <= (int)(n - 1); i++)
      scanf("%d%d%d", &an[i].first, &an[i].second, &an[i].num);
    sort(an, an + n, cmp);
    double ans = 0;
    for (int i = (0); i <= (int)(n - 1); i++) {
      sum += an[i].num;
      chmax(ans, dis(an[i].first, an[i].second));
      if (sum >= maxn) break;
    }
    if (sum >= maxn)
      printf("%.8f\n", ans);
    else
      cout << "-1" << endl;
  }
  return 0;
}
