#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  int adj_matrix[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        adj_matrix[i][j] = 0;
      } else {
        adj_matrix[i][j] = 999999999;
      }
    }
  }
  int ai[m];
  int bi[m];
  int ci[m];
  for (int i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    adj_matrix[a][b] = c;
    adj_matrix[b][a] = c;
    ai[i] = a;
    bi[i] = b;
    ci[i] = c;
  }
  int dist[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dist[i][j] = adj_matrix[i][j];
    }
  }
  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 = m;
  for (int k = 0; k < m; k++) {
    bool shortest = false;
    for (int i = 0; i < n; i++) {
      if (dist[i][ai[k]] + ci[k] == dist[i][bi[k]]) {
        shortest = true;
        break;
      }
    }
    if (shortest) {
      ans--;
    }
  }
  cout << ans << endl;
}
