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