#include <bits/stdc++.h>
using namespace std;
pair<int, vector<vector<int>>> f(const vector<vector<int>>& dist,
                                 const vector<vector<int>>& min_dist) {
  int n = dist.size() - 1;
  vector<vector<int>> res(n + 1, vector<int>(n + 1, 0x3f3f3f3f));
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    res[i][i] = 0;
    map<int, unordered_set<int>> m;
    m[0].insert(i);
    while (m.size() > 0) {
      auto p = *m.begin();
      int d = p.first, index = *p.second.begin();
      m.begin()->second.erase(index);
      if (m.begin()->second.size() == 0) {
        m.erase(d);
      }
      for (int j = 1; j <= n; j++) {
        if (res[i][j] > res[i][index] + dist[index][j] && dist[index][j] > 0) {
          if (res[i][j] != 0x3f3f3f3f) {
            m[res[i][j]].erase(j);
            if (m[res[i][j]].size() == 0) {
              m.erase(res[i][j]);
            }
          }
          res[i][j] = res[i][index] + dist[index][j];
          m[res[i][j]].insert(j);
        }
      }
    }
    if (min_dist.size() > 0) {
      for (int j = 1; j <= n; j++) {
        if (res[i][j] != min_dist[i][j]) {
          flag = 0;
          break;
        }
      }
    }
    if (flag == 0) {
      return make_pair(0, min_dist);
    }
  }
  return make_pair(1, res);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> path;
  vector<vector<int>> dist(n + 1, vector<int>(n + 1, -1));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    path.push_back({a, b, c});
    dist[a][b] = c;
    dist[b][a] = c;
  }
  int res = 0;
  vector<vector<int>> blank;
  auto temp_dist = f(dist, blank);
  auto min_dist = temp_dist.second;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    a = path[i][0];
    b = path[i][1];
    c = path[i][2];
    dist[a][b] = -1;
    dist[b][a] = -1;
    auto temp_dist = f(dist, min_dist);
    res += temp_dist.first;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  cout << res << endl;
}
