#include <bits/stdc++.h>
using namespace std;
int main(void) {
  const int INF = 1e9;
  int N, M;
  cin >> N >> M;
  int a[1005], b[1005], c[1005], dist[105][105];
  for (int i = 1; i <= M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      if (i == j) {
        dist[i][j] = 0;
      } else {
        dist[i][j] = INF;
      }
    }
  }
  for (int i = 1; i <= M; ++i) {
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  for (int k = 1; k <= N; ++k) {
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = M;
  for (int i = 1; i <= M; ++i) {
    bool shortest = false;
    for (int j = 1; j <= N; ++j) {
      if (dist[j][a[i]] + c[i] == dist[j][b[j]]) {
        shortest = true;
      }
    }
    if (shortest == true) {
      ans = ans - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
