#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
  int sum;
  int d;
} a[1010];
bool cmp(point a, point b) { return a.d < b.d; }
int main() {
  int n, m;
  while (scanf("%d %d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d %d %d", &a[i].x, &a[i].y, &a[i].sum);
      a[i].d = a[i].x * a[i].x + a[i].y * a[i].y;
    }
    sort(a, a + n, cmp);
    int x = 0;
    if (m >= 1000000) {
      printf("%.6lf\n", sqrt(x));
      continue;
    }
    int i;
    for (i = 0; i < n; i++) {
      x = a[i].d;
      m += a[i].sum;
      if (m >= 1000000) {
        printf("%.6lf\n", sqrt(x));
        break;
      }
    }
    if (i == n) puts("-1");
  }
  return 0;
}
