#include <bits/stdc++.h>
using namespace std;
bool is_uruu(int y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); }
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
int dp[100][100];
int a[5000], b[5000], c[5000];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      dp[i][j] = 999999999;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dp[a[i]][b[i]] = dp[b[i]][a[i]] = c[i];
  }
  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]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (dp[a[i]][b[i]] != c[i]) {
      ans++;
    }
  }
  cout << ans << endl;
}
