#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int table[n + 1][n + 1];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      table[i][j] = 10000000;
    }
  }
  for (int i = 0; i < n + 1; i++) {
    table[i][i] = 0;
  }
  int to[n], from[n], cost[n];
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    to[i] = a;
    from[i] = b;
    cost[i] = c;
    table[a][b] = c;
    table[b][a] = c;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        table[i][j] = min(table[i][j], table[i][k] + table[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    bool used = false;
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (table[j][k] == table[j][to[i]] + cost[i] + table[from[i]][k]) {
          used = true;
        }
        if (table[j][k] == table[j][from[i]] + cost[i] + table[to[i]][k]) {
          used = true;
        }
      }
    }
    if (!used) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
