#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m), c(m);
  int def = 1;
  for (int i = 0; i < 9; i++) {
    def *= 10;
  }
  vector<vector<int>> v(n, vector<int>(n, def));
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    v[a[i]][b[i]] = c[i];
    v[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 < n; j++) {
        if (v[i][j] > v[i][k] + v[k][j]) {
          v[i][j] = v[i][k] + v[k][j];
          v[j][i] = v[i][j];
        }
      }
    }
  }
  vector<int> l(m, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        if (a[k] == i) {
          if (v[i][j] == c[k] + v[j][b[k]]) {
            l[k] = 1;
          }
        }
        if (b[k] == i) {
          if (v[i][j] == c[k] + v[j][a[k]]) {
            l[k] = 1;
          }
        }
        if (a[k] == j) {
          if (v[i][j] == c[k] + v[i][b[k]]) {
            l[k] = 1;
          }
        }
        if (b[k] == j) {
          if (v[i][j] == c[k] + v[i][a[k]]) {
            l[k] = 1;
          }
        }
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    ans -= l[i];
  }
  cout << ans << endl;
  return 0;
}
