#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[1001], b[1001], c[1001];
long long dist[1001][1001];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> a[i] >> b[i] >> c[i];
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < n + 1; ++j) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 1000000;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < n + 1; ++j) {
      for (int k = 1; k < n + 1; ++k) {
        dist[j][k] = min(dist[j][i] + dist[i][k], dist[j][k]);
      }
    }
  }
  long long ans = m;
  for (int i = 0; i < m; ++i) {
    bool flag = true;
    for (int s = 1; s < n + 1; ++s) {
      for (int t = 1; t < n + 1; ++t) {
        if (s == t) continue;
        if (dist[s][a[i]] + dist[t][b[i]] == dist[s][t]) flag = false;
      }
    }
    if (flag) ans--;
  }
  cout << ans << endl;
}
