
#include <iostream>
#include <algorithm>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define INF 1000 * 1000;

int n, m;
int a[1000], b[1000], c[1000];
int g[100][100];

int main() {
  cin >> n >> m;
  rep(i, n)
    rep(j, n) {
      if (i == j)
        g[i][j] = 0;
      else
        g[i][j] = INF;
    }

  rep (i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;

    g[a[i]][b[i]] = g[b[i]][a[i]] = c[i];
  }

  rep(k, n)
    rep(i, n)
      rep(j, n)
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

  int count = 0;

  rep(i, m)
    count += g[a[i]][b[i]] < c[i];

  cout << count << endl;

  return 0;
}

