#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1010], b[1010], c[1010], dist[101][101];
  int N, M;
  cin >> N >> M;
  for (int i = int(0); i < int(M); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  for (int i = int(0); i < int(N); i++) {
    for (int j = int(0); j < int(N); j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = 10000000;
    }
  }
  for (int i = int(0); i < int(M); i++) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (int k = int(0); k < int(N); k++) {
    for (int i = int(0); i < int(N); i++) {
      for (int j = int(0); j < int(N); j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ret = 0;
  for (int k = int(0); k < int(M); k++) {
    bool isUsed = false;
    for (int i = int(0); i < int(N - 1); i++) {
      for (int j = int(i + 1); j < int(N); j++) {
        if (dist[i][j] == dist[i][a[k]] + c[k] + dist[b[k]][j]) isUsed = true;
      }
    }
    if (!isUsed) ret++;
  }
  cout << ret << endl;
}
