#include <bits/stdc++.h>
using namespace std;
int dp[1000][1000];
string v[1000][1000];
int main() {
  int N, M;
  cin >> N >> M;
  std::vector<int> a(M), b(M), c(M);
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i] >> c[i];
  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] = 100000000;
    }
  }
  for (int asdfg = 0; asdfg < N - 1; asdfg++) {
    for (int i = 0; i < M; i++) {
      for (int start = 0; start < N; start++) {
        if (dp[start][b[i] - 1] == dp[start][a[i] - 1] + c[i]) {
          v[start][b[i] - 1] += " " + to_string(i);
        }
        if (dp[start][b[i] - 1] > dp[start][a[i] - 1] + c[i]) {
          dp[start][b[i] - 1] = dp[start][a[i] - 1] + c[i];
          v[start][b[i] - 1] = to_string(i);
        }
      }
    }
    for (int i = 0; i < M; i++) {
      for (int start = 0; start < N; start++) {
        if (dp[start][a[i] - 1] == dp[start][b[i] - 1] + c[i]) {
          v[start][a[i] - 1] += " " + to_string(i);
        }
        if (dp[start][a[i] - 1] > dp[start][b[i] - 1] + c[i]) {
          dp[start][a[i] - 1] = dp[start][b[i] - 1] + c[i];
          v[start][a[i] - 1] = to_string(i);
        }
      }
    }
  }
  std::vector<int> pp(M, 0);
  for (int k = 0; k < M; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (v[i][j].find(to_string(k)) != string::npos) pp[k]++;
      }
    }
  }
  int ans = 0;
  for (int k = 0; k < M; k++)
    if (pp[k] == 0) ans++;
  cout << ans << endl;
}
