#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000;
struct node {
  double r;
  int num;
} c[1005];
int cmp(node a, node b) { return a.r < b.r; }
int main() {
  int n, s;
  double x, y;
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> c[i].num;
    c[i].r = sqrt(x * x + y * y);
  }
  if (s >= inf) {
    cout << 0 << endl;
    return 0;
  }
  sort(c, c + n, cmp);
  double ans;
  for (int i = 0; i < n; i++) {
    ans = c[i].r;
    s += c[i].num;
    if (s >= inf) {
      printf("%.7lf\n", ans);
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
