#include <bits/stdc++.h>
using namespace std;
const int OO = 2e9;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
long long n, k[1001], s;
double d[1001], r;
int main() {
  long long i, j;
  double x, y, tmp;
  cin >> n >> s;
  for (i = 1; i <= n; i++) {
    cin >> x >> y >> k[i];
    d[i] = sqrt(x * x + y * y);
  }
  for (i = 1; i <= n - 1; i++)
    for (j = i + 1; j <= n; j++)
      if (d[i] > d[j]) {
        tmp = d[i];
        d[i] = d[j];
        d[j] = tmp;
        k[i] += k[j];
        k[j] = k[i] - k[j];
        k[i] -= k[j];
      }
  r = 0.0;
  for (i = 1; i <= n; i++) {
    if (s >= 1000000) break;
    s += k[i];
    r = d[i];
  }
  if (s >= 1000000)
    printf("%.8lf\n", r);
  else
    cout << -1;
}
