#include <bits/stdc++.h>
const int INF = std::numeric_limits<int>::max() / 2;
const long long INFLL = std::numeric_limits<long long>::max() / 2;
const int MAX_N = 200;
const int MAX_M = MAX_N * MAX_N;
int n, m, lft[MAX_M], rgt[MAX_M], wgt[MAX_M], dis[MAX_N][MAX_N];
std::pair<double, double> eqi[MAX_N];
double max_lft[MAX_N], max_rgt[MAX_N];
double max_min(double l, double r, double d) {
  return std::min(l, r) + std::min(std::abs(l - r), d) +
         std::max(double(), d - std::abs(l - r)) / 2;
}
double min_max(double l, double r, double d) {
  return std::max(l, r) - std::min(std::abs(l - r), d) -
         std::max(double(), d - std::abs(l - r)) / 2;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  for (int i = 0; i < MAX_N; ++i) std::fill(dis[i], dis[i] + MAX_N, INF);
  for (int i = 0; i < MAX_N; ++i) dis[i][i] = 0;
  std::cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    std::cin >> lft[i] >> rgt[i] >> wgt[i];
    --lft[i];
    --rgt[i];
    dis[lft[i]][rgt[i]] = dis[rgt[i]][lft[i]] = wgt[i];
  }
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j)
        if (dis[i][j] > dis[i][k] + dis[k][j])
          dis[i][j] = dis[i][k] + dis[k][j];
  double ans = INF;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      eqi[j].first = (double)(wgt[i] + dis[rgt[i]][j] - dis[lft[i]][j]) / 2;
      eqi[j].first =
          std::min((double)wgt[i], std::max((double)0, eqi[j].first));
      eqi[j].second = max_min(dis[lft[i]][j], dis[rgt[i]][j], wgt[i]);
    }
    std::sort(eqi, eqi + n);
    max_lft[0] = eqi[0].first + eqi[0].second;
    for (int j = 1; j < n; ++j)
      max_lft[j] = std::max(max_lft[j - 1], eqi[j].first + eqi[j].second);
    max_rgt[n - 1] = wgt[i] - eqi[n - 1].first + eqi[n - 1].second;
    for (int j = n - 2; j >= 0; --j)
      max_rgt[j] =
          std::max(max_rgt[j + 1], wgt[i] - eqi[j].first + eqi[j].second);
    for (int j = 0; j + 1 < n; ++j)
      ans = std::min(ans, min_max(max_lft[j] - eqi[j].first,
                                  max_rgt[j + 1] - wgt[i] + eqi[j + 1].first,
                                  eqi[j + 1].first - eqi[j].first));
  }
  std::cout << ans << '\n';
  return 0;
}
