#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main(void) {
  int V, E;
  cin >> V >> E;
  vector<tuple<int, int, int>> es;
  for (int i = 0; i < (int)(E); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    es.emplace_back(a, b, c);
  }
  vector<vector<int>> dists(V, vector<int>(V, INF));
  for (auto &e : es) {
    int from, to, cost;
    tie(from, to, cost) = e;
    dists[from][to] = cost;
    dists[to][from] = cost;
  }
  for (int k = 0; k < (int)(V); k++)
    for (int i = 0; i < (int)(V); i++)
      for (int j = 0; j < (int)(V); j++) {
        dists[i][j] = min(dists[i][j], dists[i][k] + dists[k][j]);
      }
  int cnt = 0;
  for (int i = 0; i < (int)(E); i++) {
    bool use = false;
    for (int j = 0; j < (int)(V); j++) {
      int a, b, c;
      tie(a, b, c) = es[i];
      use |= dists[j][a] + c == dists[j][b];
    }
    cnt += !use;
  }
  cout << cnt << endl;
  return 0;
}
