#include <bits/stdc++.h>
using namespace std;
long long int d[200][200] = {}, n;
void dijkstra() {
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  complex<long double> cmpmp;
  const long long int mod = 1000000007;
  map<long long int, long long int> mp;
  string str, str2, tmp;
  long long int res = 0, y, id = 0, m = 0, a[2000], b[2000], c[2000], x, k,
                ng[2000] = {}, left = 0, dp[100][3] = {};
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i != j) {
        d[i][j] = 9999999999;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  dijkstra();
  for (int k = 0; k < m; k++) {
    for (int i = 1; i <= n; i++) {
      if (d[i][b[k]] == d[a[k]][b[k]] + d[i][a[k]]) {
        ng[i] = 1;
      }
      if (d[a[k]][i] == d[a[k]][b[k]] + d[b[k]][i]) {
        ng[i] = 1;
      }
    }
  }
  for (int k = 0; k < m; k++) {
    if (ng[k] == 1) {
      m--;
    }
  }
  cout << m - 1 << endl;
}
