#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void run();
void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
}
signed main() {
  init();
  run();
  return 0;
}
long long g[100][100];
long long a[100], b[100], c[100];
long long n, m;
void warshall_floyd(void) {
  long long i, j, k;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      if (i != j) g[i][j] = (1ll << 60);
  for (long long i = 0; i < m; i++)
    g[a[i] - 1][b[i] - 1] = g[b[i] - 1][a[i] - 1] = c[i];
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++)
        if (g[i][j] > g[i][k] + g[k][j]) g[i][j] = g[i][k] + g[k][j];
}
void run() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  warshall_floyd();
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    bool f = true;
    for (long long j = 0; j < n; j++) {
      for (long long k = 0; k < n; k++) {
        if (g[j][a[i] - 1] + c[i] + g[b[i] - 1][k] == g[j][k]) {
          f = false;
          break;
        }
      }
    }
    ans += f;
  }
  cout << ans << endl;
}
