#include "bits/stdc++.h"

using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define x first
#define y second
#define PII pair<int,int>
#define PIII pair<int,PII>
const int MOD = 1e9 + 7;
const int N = 3e5;

void slu() {
    int n, x;
    cin >> n >> x;
    vector<PII > a(n);
    for (int i = 0; i < n; i++) {
        int x, y, v;
        cin >> x >> y >> v;
        a[i].first = pow(x, 2) + pow(y, 2);
        a[i].second = v;
    }
    std::sort(a.begin(), a.end());
    for (int i = 1; i < n; i++)a[i].second += a[i - 1].second;
    int l = -1, r = n;
    while (l + 1 != r) {
        int mid = (l + r) >> 1;
        if (a[mid].second < x)l = mid;
        else r = mid;
    }
    if (r == n)cout << -1 << endl;
    else {
        double res = (double) a[r].first;
        res = pow(res, 0.5);
        cout << fixed << setprecision(14) << res << endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
//    cin >> T;
    T = 1;
    while (T--)slu();

}