#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 100 + 1;
int d[MAX_V][MAX_V];
int N, M;
void warshall_floyd() {
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (d[i][j] == 0) d[i][j] = 1000000000;
    }
  }
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  cin >> N >> M;
  vector<pair<int, int> > E(M);
  int W[1001];
  for (int i = 0; i < M; i++) {
    cin >> E[i].first >> E[i].second >> W[i];
    d[E[i].second][E[i].first] = d[E[i].first][E[i].second] = W[i];
  }
  warshall_floyd();
  int ans = 0;
  for (int e = 0; e < E.size(); e++) {
    bool flag = false;
    for (int i = 1; i <= N && !flag; i++) {
      if (d[i][E[e].second] == d[i][E[e].first] + W[e]) {
        flag = true;
      }
    }
    if (!flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
