#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e15;
long long d[110][110];
long long a[110], b[110], c[110];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  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 < m; i++) {
    bool f = false;
    for (long long j = 0; j < n; j++) {
      for (long long k = j + 1; k < n; k++) {
        if (d[j][k] == d[j][a[i]] + c[i] + d[b[i]][k]) f = true;
      }
    }
    if (!f) ans++;
  }
  cout << ans << endl;
}
