#include <bits/stdc++.h>
using namespace std;
const int inf = 1e8;
int main() {
  int N, M;
  cin >> N >> M;
  int g[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        g[i][j] = 0;
      else
        g[i][j] = inf;
    }
  }
  int u[M], v[M], cost[M];
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = g[b][a] = c;
    u[i] = a;
    v[i] = b, cost[i] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int r = 0;
  for (int i = 0; i < M; i++) {
    if (g[u[i]][v[i]] == cost[i]) r++;
  }
  cout << r << endl;
  return 0;
}
