#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m], c[n][n], d[n][n];
  int INF = 1e9;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      d[i][j] = INF;
    }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    cin >> c[a[i]][b[i]];
    c[b[i]][a[i]] = c[a[i]][b[i]];
    d[a[i]][b[i]] = c[a[i]][b[i]];
    d[b[i]][a[i]] = c[a[i]][b[i]];
  }
  cerr << d[0][1] << " " << d[1][2] << endl;
  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 = 0;
  bool used = false;
  cerr << d[0][1] << " " << d[1][2] << endl;
  for (int k = 0; k < m; k++) {
    used = false;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (i == a[k] || j == b[k]) continue;
        if (d[i][j] == d[i][a[k]] + c[a[k]][b[k]] + d[b[k]][j]) used = true;
      }
    if (d[a[k]][b[k]] == c[a[k]][b[k]]) used = true;
    if (!used) ans++;
  }
  cout << ans << endl;
}
