#include <bits/stdc++.h>
using namespace std;
int graf[105][105];
int a[1001], b[1001], c[1001];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (1 != j) graf[i][j] = 1000000009;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    graf[a[i] - 1][b[i] - 1] = c[i];
    graf[b[i] - 1][a[i] - 1] = c[i];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++)
        graf[j][k] = min(graf[j][k], graf[j][i] + graf[i][k]);
  int ans = m;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (graf[j][a[i] - 1] + c[i] == graf[j][b[i] - 1]) {
        ans--;
        break;
      } else if (graf[j][b[i] - 1] + c[i] == graf[j][a[i] - 1]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
}
