#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  vector<int> c(m);
  int i;
  for (i = 0; i < m; i++) cin >> a.at(i) >> b.at(i) >> c.at(i);
  int j, k;
  vector<vector<int>> edge(n, vector<int>(n, 100000000));
  vector<vector<int>> cost(n, vector<int>(n, 100000000));
  for (i = 0; i < n; i++) cost.at(i).at(i) = 0;
  for (i = 0; i < m; i++) {
    a.at(i)--;
    b.at(i)--;
    cost.at(a.at(i)).at(b.at(i)) = c.at(i);
    cost.at(b.at(i)).at(a.at(i)) = c.at(i);
    edge.at(a.at(i)).at(b.at(i)) = c.at(i);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < n; k++) {
        cost.at(i).at(j) =
            min(cost.at(i).at(j), cost.at(i).at(k) + cost.at(k).at(j));
      }
    }
  }
  vector<bool> ch(m, false);
  for (i = 0; i < m; i++) {
    int hi = a.at(i);
    int hj = b.at(i);
    int s, t;
    for (s = 0; s < n; s++) {
      for (t = 0; t < n; t++) {
        if (cost.at(s).at(hi) + edge.at(hi).at(hj) + cost.at(hj).at(t) ==
            cost.at(s).at(t)) {
          ch.at(i) = true;
        }
      }
    }
  }
  int ans = 0;
  for (i = 0; i < m; i++)
    if (!ch.at(i)) ans++;
  cout << ans << endl;
}
