#include <bits/stdc++.h>
using namespace std;
const int inf = 1e+9;
const long long mod = 1000000007;
const long long INF = mod * mod;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
void solve() {
  int N, M;
  cin >> N >> M;
  int d[120][120];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      d[i][j] = inf;
    }
  }
  for (int i = 0; i < N; i++) d[i][i] = 0;
  int a[1200], b[1200], c[1200];
  for (int 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 (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]);
      }
    }
  }
  bool used[120];
  for (int i = 0; i < M; i++) used[i] = false;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < M; k++) {
        if (d[i][j] == d[i][a[k]] + c[k] + d[b[k]][j]) {
          used[k] = true;
        }
        if (d[i][j] == d[i][b[k]] + c[k] + d[a[k]][j]) {
          used[k] = true;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (!used[i]) ans++;
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
