#include <bits/stdc++.h>
long long distance[1001], population[1001], n, s, i, x, y;
void swa(long long &value1, long long &value2) {
  long long tmp = value1;
  value1 = value2;
  value2 = tmp;
}
void quicksort(long long fron, long long rear) {
  if (fron >= rear) return;
  long long i1 = fron, j1 = rear, value;
  srand(time(NULL));
  value = distance[rand() % (rear - fron + 1) + fron];
  while (i1 <= j1) {
    while (distance[i1] < value) i1++;
    while (distance[j1] > value) j1--;
    if (i1 <= j1) {
      if (i1 < j1) {
        swa(distance[i1], distance[j1]);
        swa(population[i1], population[j1]);
      }
      i1++;
      j1--;
    }
  }
  quicksort(fron, j1);
  quicksort(i1, rear);
}
int main() {
  scanf("%I64d%I64d", &n, &s);
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d%I64d", &x, &y, &population[i]);
    distance[i] = x * x + y * y;
  }
  quicksort(0, n - 1);
  i = 0;
  while (i < n && s < 1000000) {
    s += population[i];
    i++;
  }
  if (i == n && s < 1000000)
    printf("-1");
  else
    printf("%.7lf", sqrt(distance[i - 1]));
  return 0;
}
