#include <bits/stdc++.h>
using namespace std;
struct edge {
  int a, b;
};
int main() {
  int N, M, dp[100][100];
  edge E[1000];
  cin >> N >> M;
  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] = 1000000000;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dp[a][b] = dp[b][a] = c;
    E[i] = (edge){a, b};
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int a = E[i].a, b = E[i].b;
    bool used = false;
    for (int s = 0; s < N; s++) {
      for (int t = 0; t < N; t++) {
        if (dp[s][t] == dp[s][a] + dp[b][t] + 1 ||
            dp[s][t] == dp[s][b] + dp[a][t] + 1)
          used = true;
      }
    }
    if (!used) ans++;
  }
  cout << ans << endl;
  return 0;
}
