#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q = 1;
  while (q-- > 0) {
    int n, s, x, y, k, fi = 0;
    cin >> n >> s;
    float ans = -1, f;
    vector<pair<float, int>> v;
    for (int i = 0; i < n; i++) {
      cin >> x >> y >> k;
      f = sqrt(x * x + y * y);
      v.push_back(make_pair(f, k));
    }
    sort(v.begin(), v.end());
    for (int i = 1; i < n; i++) v[i].second += v[i - 1].second;
    for (int i = 0; i < n; i++) {
      if (s + v[i].second >= 1000000) {
        ans = v[i].first;
        fi = 1;
        break;
      }
    }
    if (fi == 1)
      cout << fixed << setprecision(7) << ans << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
