#include <bits/stdc++.h>
using namespace std;
const long long INF = (1001001001);
const long long N = (200 + 5);
const long long MOD = 1e9 + 7;
long long adj[N][N];
long long wt[N][N];
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      adj[i][j] = INF;
      wt[i][j] = -1;
    }
    adj[i][i] = 0;
  }
  for (long long i = 1; i <= m; i++) {
    long long u, vv, c;
    cin >> u >> vv >> c;
    adj[u][vv] = c;
    adj[vv][u] = c;
    wt[u][vv] = c;
    wt[vv][u] = c;
  }
  for (long long k = 1; k <= n; k++) {
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      if (wt[i][j] == 0) continue;
      bool p = false;
      for (long long a = 1; a <= n; a++) {
        for (long long b = 1; b <= n; b++) {
          if (adj[a][b] == (adj[a][i] + adj[j][b] + wt[i][j])) p = true;
        }
      }
      if (p) ans++;
    }
  }
  cout << m - ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long tt = 1;
  while (tt--) {
    solve();
  }
}
