#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long double EPS = 1e-8;
struct Edge {
  int src, dst;
  int cost;
  Edge() {}
  Edge(int src_, int dst_, int cost_) : src(src_), dst(dst_), cost(cost_) { ; }
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<Edge> e(M);
  for (int i = 0; i < (int)(M); i++) {
    int src, dst, cost;
    cin >> src >> dst >> cost;
    --src;
    --dst;
    e[i] = Edge(src, dst, cost);
  }
  vector<vector<int>> dist(N, vector<int>(N, INF));
  for (int i = 0; i < (int)(M); i++) {
    dist[e[i].src][e[i].dst] = e[i].cost;
    dist[e[i].dst][e[i].src] = e[i].cost;
  }
  for (int k = 0; k < (int)(N); k++)
    for (int i = 0; i < (int)(N); i++)
      for (int j = 0; j < (int)(N); j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  int ret = 0;
  for (int i = 0; i < (int)(M); i++) {
    bool flag = false;
    for (int j = 0; j < (int)(N); j++)
      if (dist[j][e[i].src] + e[i].cost == dist[j][e[i].dst]) flag = true;
    if (!flag) ++ret;
  }
  cout << ret << endl;
  return 0;
}
