#include <bits/stdc++.h>
using namespace std;
long long dist[101][101];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = 10e7;
        dist[j][i] = 10e7;
      }
    }
  }
  int arr[m][3];
  for (int i = 0; i < m; i++) {
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    dist[arr[i][0] - 1][arr[i][1] - 1] = arr[i][2];
    dist[arr[i][1] - 1][arr[i][0] - 1] = arr[i][2];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (dist[arr[i][0]][arr[i][1]] > arr[i][2]) {
      ans++;
    }
  }
  cout << ans;
}
