#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  long long d[100][100], in[100][100];
  for (long long i = 0; i < 100; i++)
    for (long long j = 0; j < 100; j++) {
      d[i][j] = (1LL << 60);
      in[i][j] = (1LL << 60);
    }
  for (long long i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
    in[a][b] = c;
    in[b][a] = c;
  }
  for (long long k = 0; k < N; k++) {
    for (long long i = 0; i < N; i++) {
      for (long long j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    for (long long j = i + 1; j < N; j++) {
      if (in[i][j] == (1LL << 60)) continue;
      for (long long k = 0; k < N; k++) {
        if (d[i][j] + d[j][k] == d[i][k]) {
          ans++;
          break;
        }
      }
    }
  }
  cout << M - ans << endl;
  return 0;
}
