#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const int MN = 110;
int cost[MN][MN];
struct D {
  void solve(std::istream& cin, std::ostream& cout) {
    memset(cost, (0), sizeof(cost));
    int V, E;
    cin >> V >> E;
    vector<tuple<int, int, int> > allpairs;
    for (int i = (0); i < (E); ++i) {
      int u, v, c;
      cin >> u >> v >> c;
      --u;
      --v;
      allpairs.emplace_back(u, v, c);
      cost[u][v] = c;
      cost[v][u] = c;
    }
    for (int k = (0); k < (V); ++k) {
      for (int i = (0); i < (V); ++i) {
        for (int j = (0); j < (V); ++j) {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
      }
    }
    int res = 0;
    for (int i = (0); i < (E); ++i) {
      int a, b, c;
      tie(a, b, c) = allpairs[i];
      if (cost[a][b] != c) ++res;
    }
    cout << res << "\n";
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  D solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
