#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e2 + 1;
int N, M;
int mx[MAX_N][MAX_N];
int A[MAX_N], B[MAX_N], W[MAX_N];
const int Inf = 1e7;
void solve() {
  memset(mx, 0, sizeof(mx));
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (N); ++j)
      if (i != j) mx[i][j] = Inf;
  for (int i = 0; i < (M); ++i) mx[A[i]][B[i]] = mx[B[i]][A[i]] = W[i];
  for (int k = 0; k < (N); ++k)
    for (int i = 0; i < (N); ++i)
      for (int j = 0; j < (N); ++j)
        mx[i][j] = min(mx[i][j], mx[i][k] + mx[k][j]);
  int res = 0;
  for (int i = 0; i < (M); ++i) {
    int x = A[i], y = B[i], w = W[i];
    bool ok = false;
    for (int u = 0; u < (N); ++u)
      for (int v = 0; v < (N); ++v) {
        if (mx[u][v] == mx[u][x] + w + mx[y][v]) ok |= true;
      }
    if (!ok) ++res;
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < (M); ++i) {
    cin >> A[i] >> B[i] >> W[i];
    A[i]--, B[i]--;
  }
  solve();
  return 0;
}
