#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < (M); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  vector<vector<int> > G(N, vector<int>(N, INF));
  for (int i = 0; i < (N); ++i) {
    G[i][i] = 0;
  }
  map<pair<int, int>, bool> used;
  for (int i = 0; i < (M); ++i) {
    G[a[i]][b[i]] = c[i];
    G[b[i]][a[i]] = c[i];
    used[pair<int, int>(a[i], b[i])] = true;
  }
  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]) {
          used[pair<int, int>(i, j)] = false;
          used[pair<int, int>(i, k)] = used[pair<int, int>(k, j)] = true;
          G[i][j] = G[i][k] + G[k][j];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (M); ++i) {
    if (!used[pair<int, int>(a[i], b[i])]) ans++;
  }
  cout << ans << endl;
  return 0;
}
