#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); }
long lcm(long m, long n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);
}
long nCr(long n, long r) {
  if (n == r || r == 0) {
    return 1;
  } else {
    return (nCr(n - 1, r) + nCr(n - 1, r - 1)) % MOD;
  }
}
int N, M;
int dp[101][101];
void wf() {
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
}
int main() {
  cin >> N >> M;
  int edges[1000][3];
  for (int i = 0; i < M; i++) {
    int in, out, cost;
    cin >> in >> out >> cost;
    edges[i][0] = in - 1;
    edges[i][1] = out - 1;
    edges[i][2] = cost;
    dp[in - 1][out - 1] = cost;
    dp[out - 1][in - 1] = cost;
  }
  wf();
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int in = edges[i][0];
    int out = edges[i][1];
    int cost = edges[i][2];
    bool used = false;
    for (int s = 0; s < N; s++) {
      for (int t = 0; t < N; t++) {
        if (dp[s][in] + cost + dp[out][t] == dp[s][t]) {
          used = true;
        }
      }
    }
    if (!used) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
