#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
const int inf = 1 << 29;
int N, M;
vector<vector<int>> d(105, vector<int>(105, inf));
void floyd() {
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      if (d[i][k] == inf) continue;
      for (int j = 0; j < N; j++) {
        if (d[k][j] == inf) continue;
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) d[i][j] = 0;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  floyd();
  int ans = 0;
  for (int i = 0; i < M; i++) {
    bool flg = false;
    for (int p = 0; p < N; p++) {
      if (d[p][a[i]] + c[i] == d[p][b[i]]) flg = true;
    }
    if (!flg) ans++;
  }
  cout << ans << endl;
}
