#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main(int argc, char* argv[]) {
  int n, m;
  cin >> n >> m;
  int a[m], b[m], c[m], dist[100][100];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  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] = (1 << 30);
    }
  }
  for (int i = 0; i < m; i++) {
    int ai = a[i], bi = b[i], ci = c[i];
    dist[ai][bi] = min(dist[ai][bi], ci);
    dist[bi][ai] = min(dist[bi][ai], ci);
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    bool shortest = false;
    int ai = a[i], bi = b[i], ci = c[i];
    for (int j = 0; j < n; j++)
      if (dist[j][ai] + ci == dist[j][bi]) shortest = true;
    if (shortest) ans = ans - 1;
  }
  cout << ans << endl;
  return 0;
}
