#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 100100;
const int MOD = 1000000007;
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";
void solve(long long N, long long M, std::vector<long long> a,
           std::vector<long long> b, std::vector<long long> c) {
  vector<vector<ll>> d(110, vector<ll>(110, 1e+9));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) {
        d[i][j] = 0;
      }
    }
  }
  for (int i = 0; i < M; i++) {
    d[a[i]][b[i]] = min(c[i], d[a[i]][b[i]]);
    d[b[i]][a[i]] = min(c[i], d[b[i]][a[i]]);
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; i++) {
    bool che = false;
    for (int j = 0; j < N; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) che = true;
    }
    if (che) ans--;
  }
  cout << ans << endl;
  return;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> a(M);
  std::vector<long long> b(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &a[i]);
    a[i]--;
    scanf("%lld", &b[i]);
    b[i]--;
    scanf("%lld", &c[i]);
    c[i]--;
  }
  solve(N, M, std::move(a), std::move(b), std::move(c));
  return 0;
}
