#include <bits/stdc++.h>
using namespace std;
struct A {
  int u, v, w;
  int next;
  int id;
  bool operator<(const A& b) const { return w > b.w; }
} star[11111], pre[11111];
int t, n;
int u, v, w;
int dis[11111], vis[11111], head[11111], eg;
bool svis[11111];
void Init() {
  memset(vis, 0, sizeof vis);
  memset(pre, 0, sizeof pre);
  for (int i = 0; i < 11111; i++) dis[i] = 9999999999;
}
void AddEdge(int u, int v, int w, int id) {
  ++eg;
  star[eg] = (A){u, v, w, head[u]};
  star[eg].id = id;
  head[u] = eg;
}
void Dijkstra(int s) {
  priority_queue<A> P;
  A t1, t2;
  t1.v = s;
  P.push(t1);
  dis[s] = 0;
  while (!P.empty()) {
    t1 = P.top();
    P.pop();
    int u = t1.v;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; ~i; i = star[i].next) {
      int v = star[i].v;
      if (!vis[v] && dis[v] > dis[u] + star[i].w) {
        dis[v] = star[i].w + dis[u];
        t2.u = u;
        t2.v = v;
        t2.w = dis[v];
        pre[v] = star[i];
        P.push(t2);
      }
    }
  }
}
int main() {
  memset(head, -1, sizeof head);
  eg = 0;
  int n, m;
  int u, v, w;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    AddEdge(u, v, w, i);
    AddEdge(v, u, w, i);
  }
  for (int i = 1; i <= n; i++) {
    Init();
    Dijkstra(i);
    for (int j = 1; j <= n; j++) {
      if (i != j) {
        A tmp = pre[j];
        while (tmp.u != i) {
          svis[tmp.id] = 1;
          tmp = pre[tmp.u];
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (!svis[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
