#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int inf = 1e8;
int c[N][N], edge[N][N];
int dist[N];
vector<int> conn[N];
bool inpath[N];
int n;
void dijkstra(int u) {
  fill_n(dist, N, inf);
  vector<bool> processed(N, false);
  vector<int> parent(N, -1);
  dist[u] = 0;
  priority_queue<pair<int, int> > pq;
  pq.emplace(0, u);
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (processed[u]) continue;
    processed[u] = true;
    for (int v : conn[u]) {
      if (dist[v] > dist[u] + c[u][v]) {
        dist[v] = dist[u] + c[u][v];
        parent[v] = u;
        pq.emplace(-dist[v], v);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (i == u) continue;
    int x = i;
    while (1) {
      int p = parent[x];
      if (p == -1) break;
      inpath[edge[p][x]] = true;
      x = p;
    }
  }
}
int main() {
  int m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    c[u][v] = c[v][u] = w;
    edge[u][v] = edge[v][u] = i;
    conn[u].emplace_back(v);
    conn[v].emplace_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    dijkstra(i);
  }
  int res = 0;
  for (int i = 1; i <= m; ++i)
    if (!inpath[i]) res++;
  cout << res << endl;
}
