#include <bits/stdc++.h>
using namespace std;
int n, s, x, y, z, r, cnt;
vector<pair<pair<int, int>, pair<int, int> > > v;
int main() {
  cin >> n >> s;
  s = 1000000 - s;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> z;
    int temp = x * x + y * y;
    pair<int, int> temp1 = pair<int, int>(x, y);
    pair<int, int> temp2 = pair<int, int>(temp, z);
    v.push_back(pair<pair<int, int>, pair<int, int> >(temp2, temp1));
  }
  sort(v.begin(), v.end());
  bool flag = false;
  for (int i = 0; i < n; i++) {
    r = v[i].first.first;
    s = s - v[i].first.second;
    if (s <= 0) {
      flag = true;
      break;
    }
  }
  if (!flag)
    cout << "-1";
  else {
    double temp = r;
    cout << fixed << setprecision(7) << sqrt(temp);
  }
}
