#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y, k;
  double dis;
  friend bool operator<(Point a, Point b) { return a.dis < b.dis; }
};
Point p[1010];
int main() {
  int n, m, i;
  double d;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> p[i].x >> p[i].y >> p[i].k;
    p[i].dis = double(p[i].x * p[i].x + p[i].y * p[i].y);
  }
  sort(p, p + n);
  d = 0;
  for (i = 0; i < n; i++) {
    m += p[i].k;
    d = p[i].dis;
    if (m >= 1000000) break;
  }
  if (m >= 1000000)
    printf("%.7lf\n", sqrt(d));
  else
    cout << "-1\n";
  return 0;
}
