#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int N, M;
int a[110], b[110], c[110];
int d[110][110];
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  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 ans = M;
  for (int i = 0; i < M; i++) {
    bool ok = false;
    for (int j = 0; j < N; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) ok = true;
    }
    ans -= ok;
  }
  cout << (ans) << endl;
  return 0;
}
