#include <bits/stdc++.h>
int getint() {
  char ch = getchar();
  int ret = 0;
  bool flag = true;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') flag = false, ch = getchar();
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return flag ? ret : -ret;
}
using namespace std;
double dist[2000];
int x[2000], rk[2000], y[2000], k[2000], num, tot, s, n;
bool cmp(const int& a, const int& b) { return dist[a] < dist[b]; }
int main() {
  cin >> n >> s;
  s = 1000000 - s;
  for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> k[i], num += k[i];
  for (int i = 1; i <= n; i++) dist[i] = sqrt(x[i] * x[i] + y[i] * y[i]);
  for (int i = 1; i <= n; i++) rk[i] = i;
  if (num < s) return puts("-1"), 0;
  sort(rk + 1, rk + n + 1, cmp);
  tot = 0;
  for (int i = 1; i <= n; i++) {
    int v = rk[i];
    tot += k[v];
    if (tot >= s) {
      printf("%.8lf", dist[v]);
      return 0;
    }
  }
  return 0;
}
