#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > a;
  int n, s;
  scanf("%d%d", &n, &s);
  s = 1000000 - s;
  for (int i = (int)(0); i <= (int)((n)-1); ++i) {
    int x, y, t;
    scanf("%d%d%d", &x, &y, &t);
    a.push_back(make_pair(x * x + y * y, t));
  }
  sort(a.begin(), a.end());
  size_t cur = 0;
  int ct = 0;
  int ans = 0;
  while (ct < s && cur < a.size()) {
    ct += a[cur].second;
    ans = a[cur].first;
    ++cur;
  }
  if (ct < s)
    printf("-1\n");
  else
    printf("%.9lf\n", sqrt(double(ans)));
  return 0;
}
