#include <bits/stdc++.h>
using namespace std;
const long long INF = 922337203685477580;
const int MAX = 100;
int a[MAX], b[MAX], c[MAX];
long long d[MAX][MAX];
void Warshall_Floyd(long long d[MAX][MAX], int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INF) continue;
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      d[i][j] = ((i == j) ? 0 : INF);
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  Warshall_Floyd(d, N);
  int ans = 0;
  for (int i = 0; i < M; i++) {
    bool is_included = false;
    for (int s = 0; s < N; s++) {
      for (int t = 0; t < N; t++) {
        if (d[s][a[i]] + c[i] + d[b[i]][t] == d[s][t]) {
          is_included = true;
        }
      }
    }
    if (!is_included) ans++;
  }
  cout << ans << endl;
  return 0;
}
