#include <bits/stdc++.h>
using namespace std;
const int N = 123;
const int inf = 1e9;
const int mod = 1e9 + 7;
int n, dp[N][N], m;
void upd(int &a, int b) { a = min(a, b); }
struct edge {
  int from, to, cost;
} e[N * N];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (i != j) dp[i][j] = inf;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    upd(dp[a][b], c);
    upd(dp[b][a], c);
    e[i] = {a, b, c};
  }
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    bool fail = 0;
    for (int from = 1; from <= n && fail == 0; from++) {
      for (int to = 1; to <= n && fail == 0; to++) {
        int now = dp[from][e[i].from] + e[i].cost + dp[e[i].to][to];
        now = min(now, dp[from][e[i].to] + e[i].cost + dp[e[i].from][to]);
        if (now == dp[from][to]) {
          fail = 1;
          break;
        }
      }
    }
    if (!fail) ans++;
  }
  cout << ans << endl;
  return 0;
}
