#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> adj[m];
  int table[n][n];
  int c[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      c[i][j] = INF;
    }
  }
  bool candidate[m];
  for (int i = 0; i < m; i++) {
    int a, b, x;
    cin >> a >> b >> x;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
    table[a][b] = table[b][a] = i;
    c[a][b] = c[b][a] = x;
    candidate[i] = false;
  }
  for (int i = 0; i < n; i++) {
    bool used[n];
    fill(used, used + n, false);
    int d[n + 1];
    fill(d, d + n + 1, INF);
    d[i] = 0;
    int parent[n];
    for (int j = 0; j < n; j++) {
      parent[j] = j;
    }
    while (true) {
      int u = n;
      for (int j = 0; j < n; j++) {
        if (!used[j] && d[j] < d[u]) u = j;
      }
      if (u == n) break;
      used[u] = true;
      if (u != parent[u]) candidate[table[u][parent[u]]] = true;
      for (int j = 0; j < n; j++) {
        int dn = d[u] + c[j][u];
        if (dn <= d[j]) {
          d[j] = dn;
          parent[j] = u;
        }
      }
    }
  }
  int ans = 0;
  for (bool b : candidate) {
    if (!b) ans++;
  }
  cout << ans << endl;
  return 0;
}
