#include <bits/stdc++.h>
using namespace std;
int adjacent[110][110] = {};
int visited[110];
int cost[110];
int iprev[110];
bool used[110][110] = {};
void search(int start, int n) {
  int min;
  int next;
  for (int i = 0; i < n; i++) {
    visited[i] = false;
    cost[i] = 100000000;
    iprev[i] = 0;
  }
  cost[start] = 0;
  do {
    min = 100000000;
    next = -1;
    visited[start] = true;
    for (int i = 0; i < n; i++) {
      if (visited[i]) continue;
      if (adjacent[start][i]) {
        if (cost[i] > (cost[start] + adjacent[start][i])) {
          cost[i] = cost[start] + adjacent[start][i];
          iprev[i] = start;
        }
      }
      if (cost[i] < min) {
        min = cost[i];
        next = i;
      }
    }
    start = next;
  } while (start != -1);
  for (int i = 0; i < n; i++) {
    used[i][iprev[i]] = true;
    used[iprev[i]][i] = true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    adjacent[a][b] = c;
    adjacent[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    search(i, n);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (adjacent[i][j] != 0 && !used[i][j]) ans++;
    }
  }
  cout << ans << endl;
}
