#include <bits/stdc++.h>
using namespace std;
int N, M;
int e[101][101];
int d[101][101];
void warshall_floyd() {
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  memset(e, -1, sizeof(e));
  for (int i = 0; i < N; i++) {
    fill(d[i], d[i] + 101, 1000000007);
  }
  cin >> N >> M;
  int a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  warshall_floyd();
  map<pair<int, int>, bool> m;
  for (int s = 0; s < N; s++) {
    for (int i = 0; i < N; i++) {
      if (s == i) continue;
      for (int j = i + 1; j < N; j++) {
        if (d[s][j] == d[s][i] + d[i][j]) {
          pair<int, int> p = {i, j};
          m[p] = true;
        }
      }
    }
  }
  int ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second) {
      ans++;
    }
  }
  printf("%d\n", M - ans);
  return 0;
}
