#include <bits/stdc++.h>
using namespace std;
const int N = 111111;
const int INF = 1000000000, mod = 1000000007;
const long long LLINF = 1000000000000000000ll;
pair<int, double> city[N];
bool cmp(const pair<int, double>& a, const pair<int, double>& b) {
  return a.second < b.second || (a.second == b.second && a.first > b.first);
}
int main() {
  int n, cnt;
  scanf("%d%d", &n, &cnt);
  cnt = 1000000 - cnt;
  for (int i = 0; i < n; ++i) {
    int x, y, pop;
    scanf("%d%d%d", &x, &y, &pop);
    city[i] = make_pair(pop, hypot(abs(x), abs(y)));
  }
  sort(city, city + n, cmp);
  for (int i = 0; i < n; ++i) {
    if (i > 0) city[i].first += city[i - 1].first;
  }
  printf("%.10f\n",
         city[n - 1].first >= cnt
             ? (*lower_bound(city, city + n, make_pair(cnt, .0))).second
             : -1.);
  return 0;
}
