#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
const unsigned int MOD = 1000000003;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool cmp(pair<double, int> x, pair<double, int> y) {
  if (x.first == y.first) {
    return x.second > y.second;
  }
  return x.first < y.first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, x, y, k, s;
  cin >> n >> s;
  vector<pair<double, int> > v;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> k;
    v.push_back({sqrt(x * x + y * y), k});
  }
  sort(v.begin(), v.end(), cmp);
  int i = 0;
  for (i = 0; i < n; i++) {
    s = s + v[i].second;
    if (s >= MAX) {
      break;
    }
  }
  if (s >= MAX)
    cout << fixed << setprecision(6) << v[i].first << endl;
  else
    cout << "-1" << endl;
  return 0;
}
