#include <bits/stdc++.h>
using namespace std;
pair<double, int> p[1005];
bool func(pair<double, int> a, pair<double, int> b) {
  if (a.first < b.first)
    return true;
  else if (a.first == b.first)
    return a.second > b.second;
  else
    return false;
}
int main() {
  int n, s;
  cin >> n >> s;
  int pop = 0;
  for (int i = 0; i < n; i++) {
    double x, y;
    scanf("%lf %lf %d", &x, &y, &p[i].second);
    p[i].first = sqrt(x * x + y * y);
    pop += p[i].second;
  }
  if ((1000000 - s) > pop)
    printf("-1\n");
  else {
    sort(p, p + n, func);
    int now = 0;
    int id = 0;
    while (now < (1000000 - s)) {
      now += p[id].second;
      id++;
    }
    printf("%.8lf\n", p[id - 1].first);
  }
}
