#include <bits/stdc++.h>
using namespace std;
class WarshallFloyd {
 public:
  WarshallFloyd(int sz) : size(sz), cost(size, vector<int>(size, INT_MAX / 2)) {
    for (int i = 0; i < size; i++) cost[i][i] = 0;
  }
  void calc(void) {
    for (int k = 0; k < size; k++)
      for (int i = 0; i < size; i++)
        for (int j = 0; j < size; j++)
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
  }
  void setCost(int src, int dst, int c) {
    cost[src][dst] = c;
    cost[dst][src] = c;
  }
  int getCost(int src, int dst) { return cost[src][dst]; }

 private:
  const int size;
  vector<vector<int>> cost;
};
int main(void) {
  int N, M;
  cin >> N >> M;
  WarshallFloyd wf(N);
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    wf.setCost(a[i], b[i], c[i]);
  }
  wf.calc();
  int ret = M;
  for (int i = 0; i < M; i++) {
    bool used = false;
    for (int j = 0; j < N; j++)
      if (wf.getCost(j, b[i]) - wf.getCost(j, a[i]) == c[i]) used = true;
    if (used == true) ret--;
  }
  cout << ret << endl;
  return 0;
}
