#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a[100], b[100], c[100];
  int dist[100][100];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      dist[i][j] = 1001001001;
    }
  }
  for (int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    dist[a[i] - 1][b[i] - 1] = c[i];
    dist[b[i] - 1][a[i] - 1] = c[i];
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; ++i) {
    for (int s = 0; s < N; ++s) {
      if (dist[s][a[i] - 1] + c[i] == dist[s][b[i] - 1]) {
        ++ans;
        break;
      }
    }
  }
  ans = M - ans;
  cout << ans << endl;
}
