#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long G[100][100];
void warshall() {
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      for (long long k = 0; k < N; k++) {
        G[j][k] = min(G[j][k], G[j][i] + G[i][k]);
      }
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (long long i = 0; i < 100; i++) {
    for (long long j = 0; j < 100; j++) G[i][j] = 1000000000;
  }
  cin >> N >> M;
  vector<long long> a(M);
  vector<long long> b(M);
  vector<long long> c(M);
  for (long long i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G[a[i]][b[i]] = c[i];
    G[b[i]][a[i]] = c[i];
  }
  warshall();
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
    }
  }
  long long ans = 0;
  for (long long k = 0; k < M; k++) {
    bool F = true;
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        if (G[i][a[k]] + c[k] + G[b[k]][j] == G[i][j] && i < a[k] && b[k] < j &&
            i < j)
          F = false;
        if (a[k] == 0 && b[k] == 1) {
        }
      }
    }
    if (F) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
