#include <bits/stdc++.h>
using namespace std;
pair<double, int> a[100500];
int n;
int s;
int main() {
  scanf("%d %d", &n, &s);
  for (int i = 0; i < n; i++) {
    int x, y, t;
    scanf("%d %d %d", &x, &y, &t);
    a[i] = make_pair(sqrt(x * x + y * y), t);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (s + a[i].second >= 1000000) {
      printf("%.17f", a[i].first);
      return 0;
    } else {
      s += a[i].second;
    }
  }
  printf("-1");
  return 0;
}
