#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 1e5 + 5;
const long long int INF = 2e18 + 10;
const int inf = 1e9 + 10;
void solve() {
  int n, m;
  cin >> n >> m;
  int a[n + 1], b[n + 1], w[n + 1];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> w[i];
    a[i]--, b[i]--;
  }
  int dist[n + 1][n + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = inf;
    }
  }
  for (int i = 0; i < m; i++) {
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], w[i]);
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], w[i]);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
  int ans = m;
  for (int i = 0; i < m; i++) {
    bool shortest = false;
    for (int j = 0; j < n; j++) {
      if (dist[j][a[i]] + w[i] == dist[j][b[i]]) shortest = true;
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
