#include <bits/stdc++.h>
using namespace std;
void fastInOut() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
}
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
bool cmp(pair<pair<int, int>, int> x, pair<pair<int, int>, int> y) {
  double sum1;
  double sum2;
  int x1 = x.first.first;
  int y1 = x.first.second;
  int x2 = y.first.first;
  int y2 = y.first.second;
  sum1 = sqrt((x1 * x1) + (y1 * y1));
  sum2 = sqrt((x2 * x2) + (y2 * y2));
  return sum1 < sum2;
}
int main() {
  fastInOut();
  int n, sum;
  cin >> n >> sum;
  pair<pair<int, int>, int> arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first.first;
    cin >> arr[i].first.second;
    cin >> arr[i].second;
  }
  double radius = 0;
  sort(arr, arr + n, cmp);
  for (int i = 0; i < n; i++) {
    if (sum >= 1000000) break;
    int x1 = arr[i].first.first;
    int y1 = arr[i].first.second;
    double sum1 = sqrt((x1 * x1) + (y1 * y1));
    if (sum1 > radius) radius = sum1;
    sum += arr[i].second;
  }
  if (sum >= 1000000)
    cout << fixed << setprecision(7) << radius << endl;
  else
    cout << -1;
}
