#include <bits/stdc++.h>
using namespace std;
struct Toado {
  int x, y, z;
  Toado(int a = 0, int b = 0, int c = 0) {
    x = a;
    y = b;
    z = c;
  }
};
bool option(Toado &a, Toado &b) {
  if (sqrt(a.x * a.x + a.y * a.y) < sqrt(b.x * b.x + b.y * b.y)) {
    return true;
  }
  return false;
}
int main() {
  long n, s;
  cin >> n >> s;
  vector<Toado> v;
  for (int i = 0; i < n; i++) {
    Toado temp;
    cin >> temp.x >> temp.y >> temp.z;
    v.push_back(temp);
  }
  sort(v.begin(), v.end(), option);
  double res = s;
  for (int i = 0; i < n; i++) {
    double temp = sqrt(v[i].x * v[i].x + v[i].y * v[i].y);
    res = res + v[i].z;
    if (res >= 1000000) {
      cout << setprecision(8) << temp;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}
