#include <bits/stdc++.h>
using namespace std;
long long a[10000][10000], n, m, k, i, j;
long long x[1010], y[1010], z[1010], sum;
const int inf = 1e10;
int main() {
  while (cin >> n >> m) {
    sum = m;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        a[i][j] = inf;
      }
      a[i][i] = 0;
    }
    for (i = 1; i <= m; i++) {
      cin >> x[i] >> y[i] >> z[i];
      a[x[i]][y[i]] = z[i];
      a[y[i]][x[i]] = z[i];
    }
    for (k = 1; k <= n; k++) {
      for (i = 1; i <= n; i++) {
        for (j = 1; j <= n; j++) {
          a[i][j] = min(a[i][k] + a[k][j], a[i][j]);
        }
      }
    }
    for (i = 1; i <= n; i++) {
      if (a[i][x[i]] + z[i] == a[x[i]][y[i]]) sum--;
    }
    cout << sum << endl;
  }
  return 0;
}
