#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n, s, sum = 0, temp;
double ans;
struct node {
  int x, y;
  int p;
} maze[maxn];
bool cmp(node a, node b) {
  if ((a.x * a.x + a.y * a.y) == (b.x * b.x + b.y * b.y)) return a.p > b.p;
  return (a.x * a.x + a.y * a.y) < (b.x * b.x + b.y * b.y);
}
int main() {
  cin >> n >> s;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &maze[i].x, &maze[i].y, &maze[i].p);
    sum += maze[i].p;
  }
  temp = 1000000 - s;
  if (sum < temp) {
    cout << -1 << endl;
    return 0;
  }
  sort(maze, maze + n, cmp);
  int i;
  for (i = 0; i < n; i++) {
    temp -= maze[i].p;
    if (temp <= 0) break;
  }
  ans = (double)sqrt(maze[i].x * maze[i].x + maze[i].y * maze[i].y);
  printf("%.7lf\n", ans);
  return 0;
}
