#include <bits/stdc++.h>
using namespace std;
const int inf = 1e8;
int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M], c[M];
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i] >> c[i];
  int g[N][N];
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      if (i != j) g[i][j] = inf;
  for (int i = 0; i < M; i++) {
    g[a[i] - 1][b[i] - 1] = c[i];
    g[b[i] - 1][a[i] - 1] = c[i];
  }
  int next[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      next[i][j] = j;
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (g[i][j] > g[i][k] + g[k][j]) {
          g[i][j] = g[i][k] + g[k][j];
          next[i][j] = next[i][k];
        }
      }
    }
  }
  set<pair<int, int> > used;
  for (int start = 0; start < N; start++) {
    for (int goal = 0; goal < N; goal++) {
      if (start == goal) continue;
      for (int i = start; i != goal; i = next[i][goal]) {
        used.insert(pair<int, int>(i, next[i][goal]));
        used.insert(pair<int, int>(next[i][goal], i));
      }
    }
  }
  cout << M - used.size() / 2 << endl;
  return 0;
}
