#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int a[M + 1], b[M + 1], c[M + 1];
  int dist[N][N];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 100000000;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[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++) {
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; i++) {
    bool shortest = false;
    for (int j = 0; j < N; j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
        shortest = true;
      }
    }
    if (shortest) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
