#include <bits/stdc++.h>
using namespace std;
const long long N = 101;
const long long MAX = N * N * 1001LL;
long long graph[N][N];
struct edge {
  int u, v, w;
  edge(int _u = -1, int _v = -1, int _w = -1) : u(_u), v(_v), w(_w) {}
};
istream& operator>>(istream& i, edge& e) {
  i >> e.u >> e.v >> e.w;
  return i;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) graph[i][j] = (i == j ? 0 : MAX);
  edge e[m];
  for (int i = 0; i < m; i++) {
    cin >> e[i];
    graph[e[i].u][e[i].v] = e[i].w;
    graph[e[i].v][e[i].u] = e[i].w;
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (graph[i][k] + graph[k][j] < graph[i][j])
          graph[i][j] = graph[i][k] + graph[k][j];
  int ans = m;
  for (int i = 0; i < m; i++) {
    edge temp = e[i];
    bool ok = 0;
    for (int j = 0; j < n; j++)
      if (graph[j][temp.u] + temp.w == graph[j][temp.v]) ok = 1;
    ans -= ok;
  }
  cout << ans;
  return 0;
}
