#include <bits/stdc++.h>
using namespace std;
const int MAX = 200;
const int INF = 1e5;
int N, M;
int cost[MAX][MAX];
bool flag[2010];
int main() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cost[i][j] = (i == j ? 0 : INF);
    }
  }
  cin >> N >> M;
  int a[M], b[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i], --b[i];
    cost[a[i]][b[i]] = cost[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++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (cost[a[i]][b[i]] != c[i]) ++ans;
  }
  cout << ans << endl;
  return 0;
}
