#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
int n, m, a[100], b[100], c[100];
long long D[100][100];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      D[i][j] = INF;
    }
    D[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i] -= 1;
    b[i] -= 1;
    D[a[i]][b[i]] = c[i];
    D[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++) {
        D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
        D[j][i] = D[i][j];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (D[a[i]][b[i]] != c[i]) ans += 1;
  }
  cout << ans << endl;
  return 0;
}
