#include <bits/stdc++.h>
using namespace std;
struct pp {
  int sum;
  int dis;
};
pp num[1100];
int cmp(pp a, pp b) { return a.dis < b.dis; }
int main() {
  int i, j, sum, m, n, a, b, p;
  scanf("%d%d", &n, &p);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &a, &b, &num[i].sum);
    num[i].dis = ((a * a) + (b * b));
  }
  sort(num, num + n, cmp);
  i = 0;
  while (i < n && p < 1000000) {
    p += num[i].sum;
    i++;
  }
  if (p >= 1000000) {
    printf("%.7lf", sqrt((double)(num[i - 1].dis)));
  } else
    printf("-1");
}
