#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const long long MOD = 1e9 + 7;
long long n, m;
long long dp[110][110];
long long d[110][110];
int main() {
  cin >> n >> m;
  for (long long i = 0; i < (n); i++)
    for (long long j = 0; j < (n); j++) dp[i][j] = INF;
  for (long long i = 0; i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dp[a][b] = c;
    dp[b][a] = c;
    d[a][b] = c;
  }
  for (long long i = 0; i < (n); i++) {
    for (long long j = 0; j < (n); j++) {
      for (long long k = 0; k < (n); k++) {
        dp[i][j] = min(dp[i][k] + dp[k][j], dp[i][j]);
      }
    }
  }
  int ans = 0;
  for (long long i = 0; i < (n); i++) {
    for (long long j = 0; j < (n); j++) {
      if (dp[i][j] < d[i][j]) ans++;
    }
  }
  cout << ans << endl;
}
