#include <bits/stdc++.h>
using namespace std;
const int inf = 100000000;
int n, m;
int dist[1100][1100];
int aa[1100];
int bb[1100];
int cc[1100];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  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] = inf;
      }
    }
  }
  cin >> n >> m;
  int a, b, c;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    aa[i] = a;
    bb[i] = b;
    cc[i] = c;
    dist[a][b] = dist[b][a] = c;
  }
  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 i = 0; i < m; i++) {
    bool shortest = false;
    for (int j = 0; j < n; j++) {
      if (dist[j][aa[i]] + cc[i] == dist[j][bb[i]]) {
        shortest = true;
      }
    }
    if (shortest == true) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
