#include <bits/stdc++.h>
using namespace std;
struct node {
  double dist;
  long long pop;
} ele[3005];
bool comp(struct node a, struct node b) { return a.dist < b.dist; }
vector<long long> v[10005];
long long visited[10005] = {0};
int flag = 0;
void dfs(long long node, long long parent) {
  visited[node] = 1;
  for (long long i = 0; i < v[node].size(); i++) {
    if (v[node][i] == parent) continue;
    if (visited[v[node][i]])
      flag = 1;
    else
      dfs(v[node][i], node);
  }
}
double cal_dist(long long x, long long y) {
  return sqrt(abs(x - 0) * abs(x - 0) + abs(y - 0) * abs(y - 0));
}
int main() {
  int n;
  long long pop, x, y;
  cin >> n >> pop;
  for (long long i = 0; i < n; i++) {
    cin >> x >> y >> ele[i].pop;
    ele[i].dist = cal_dist(x, y);
  }
  sort(ele, ele + n, comp);
  for (long long i = 0; i < n; i++) {
    if (pop + ele[i].pop >= 1000000) {
      printf("%0.12lf", ele[i].dist);
      return 0;
    }
    pop += ele[i].pop;
  }
  cout << -1;
  return 0;
}
