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