#include <bits/stdc++.h>
using namespace std;
int mindis(vector<vector<long long>> dis, long long E, queue<long long> Q,
           vector<long long> point, long long N) {
  long long now;
  while (!Q.empty()) {
    now = Q.front();
    for (int i = 0; i < N; i++) {
      if (dis[now][i] != 0) {
        if (point[now] + dis[now][i] < point[i]) {
          Q.push(i);
          point[i] = point[now] + dis[now][i];
        }
      }
    }
    Q.pop();
  }
  return point[E];
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> abc(M, vector<long long>(3, 0));
  vector<vector<long long>> dis(N, vector<long long>(N, 0));
  for (int i = 0; i < M; i++) {
    cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    abc[i][0]--;
    abc[i][1]--;
    dis[abc[i][0]][abc[i][1]] = abc[i][2];
    dis[abc[i][1]][abc[i][0]] = abc[i][2];
  }
  long long ans = 0;
  for (int i = 0; i < M; i++) {
    queue<long long> Q;
    Q.push(abc[i][0]);
    vector<long long> point(N, 2000000);
    point[abc[i][0]] = 0;
  }
  cout << ans << endl;
}
