#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using P = pair<int, int>;
int n, m;
vector<vector<int>> dist(100, vector<int>(100, 1e9));
vector<vector<int>> nex(100, vector<int>(100, -1));
void warshall_froyd() {
  for (int k = 0; k < (int)(n); k++) {
    for (int i = 0; i < (int)(n); i++) {
      for (int j = 0; j < (int)(n); j++) {
        if (dist[i][k] + dist[k][j] < dist[i][j]) {
          dist[i][j] = dist[i][k] + dist[k][j];
          nex[i][j] = nex[i][k];
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) {
    for (int j = 0; j < (int)(n); j++) {
      if (i == j) dist[i][j] = 0;
      nex[i][j] = j;
    }
  }
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = min(c[i], dist[a[i]][b[i]]);
    dist[b[i]][a[i]] = min(c[i], dist[a[i]][b[i]]);
  }
  warshall_froyd();
  int ans = m;
  for (int i = 0; i < (int)(m); i++) {
    bool flag = false;
    for (int j = 0; j < (int)(n); j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) flag = true;
      if (flag) ans--;
    }
  }
  cout << ans << endl;
}
