#include <bits/stdc++.h>
using namespace std;
long long ct[1005][1005];
long long n, m;
long long dp[1005][1005];
int main() {
  cin >> n >> m;
  memset(ct, -1, sizeof(ct));
  ;
  for (int i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    ct[a][b] = ct[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        dp[i][j] = 0;
      else
        dp[i][j] = (ct[i][j] == -1 ? long long(1e15) : ct[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ;
      if (i != j && ct[i][j] != -1) {
        if (dp[i][j] != ct[i][j]) ans++;
      }
    }
  }
  cout << ans / 2 << endl;
}
