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