#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  for (int i = (int)(0); i < (int)(m); ++i) cin >> a[i] >> b[i] >> c[i];
  for (int i = (int)(0); i < (int)(m); ++i) a[i]--, b[i]--;
  vector<vector<int>> graph(n, vector<int>(n, INF));
  for (int i = (int)(0); i < (int)(m); ++i) {
    graph[a[i]][b[i]] = c[i];
    graph[b[i]][a[i]] = c[i];
  }
  for (int k = (int)(0); k < (int)(n); ++k)
    for (int i = (int)(0); i < (int)(n); ++i)
      for (int j = (int)(0); j < (int)(n); ++j) {
        graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
      }
  int ans = 0;
  for (int s = (int)(0); s < (int)(m); ++s) {
    vector<vector<int>> cur(n, vector<int>(n, INF));
    for (int i = (int)(0); i < (int)(m); ++i)
      if (s != i) {
        cur[a[i]][b[i]] = c[i];
        cur[b[i]][a[i]] = c[i];
      }
    for (int k = (int)(0); k < (int)(n); ++k)
      for (int i = (int)(0); i < (int)(n); ++i)
        for (int j = (int)(0); j < (int)(n); ++j) {
          cur[i][j] = min(cur[i][j], cur[i][k] + cur[k][j]);
        }
    bool flag = true;
    for (int i = (int)(0); i < (int)(n); ++i)
      for (int j = (int)(0); j < (int)(n); ++j)
        if (cur[i][j] != graph[i][j]) flag = false;
    if (flag) ans++;
  }
  cout << ans << endl;
}
