#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> A(N, vector<long long>(N, (1ll << 60)));
  for (long long i = (long long)(0); i < (long long)(M); i++) {
    long long X, Y, Z;
    cin >> X >> Y >> Z;
    A[X - 1][Y - 1] = Z;
    A[Y - 1][X - 1] = Z;
  }
  vector<vector<bool>> F(N, vector<bool>(N));
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    vector<long long> memo(N);
    memo[i] = -1;
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        Q;
    Q.push(make_pair(0, i));
    vector<long long> B(N, 1000000007);
    B[i] = 0;
    while (Q.size() > 0) {
      long long X = Q.top().second, Y = Q.top().first;
      Q.pop();
      for (long long j = (long long)(0); j < (long long)(N); j++) {
        if (B[j] >= Y + A[X][j]) {
          B[j] = Y + A[X][j];
          Q.push(make_pair(Y + A[X][j], j));
          memo[i] = X;
        }
      }
    }
    for (long long i = (long long)(0); i < (long long)(N); i++) {
      long long P = i;
      while (memo[P] != -1) {
        F[P][memo[P]] = 1;
        P = memo[P];
      }
    }
  }
  long long ans = 0;
  for (long long i = (long long)(0); i < (long long)(N); i++) {
    for (long long j = (long long)(0); j < (long long)(N); j++) {
      if (F[i][j]) ans++;
    }
  }
  cout << M - ans / 2 << endl;
}
