#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1100;
pair<double, int> a[MAXN];
int main() {
  int n, s;
  cin >> n >> s;
  s = 1000000 - s;
  for (int i = 1; i <= n; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    double f = sqrt(x * x + y * y);
    a[i].first = f;
    a[i].second = z;
  }
  sort(a + 1, a + 1 + n);
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    if (s <= 0)
      break;
    else
      s -= a[i].second, ans = a[i].first;
  }
  if (s <= 0)
    printf("%.7lf\n", ans);
  else
    cout << -1 << endl;
  return 0;
}
