#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long INF = 1000000000000000;
long long dist[105][105];
void init() {
  for (int i = 0; i < 105; i++) {
    for (int j = 0; j < 105; j++) {
      dist[i][j] = INF;
    }
  }
}
void wf() {
  for (int k = 0; k < 105; k++) {
    for (int i = 0; i < 105; i++) {
      for (int j = 0; j < 105; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}
int main() {
  init();
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), cost(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> cost[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = dist[b[i]][a[i]] = cost[i];
  }
  wf();
  int ans = M;
  for (int i = 0; i < M; i++) {
    bool used = false;
    for (int s = 0; s < N; s++) {
      if (dist[s][a[i]] + cost[i] == dist[s][b[i]]) {
        used = true;
      }
    }
    ans -= used;
  }
  cout << ans << endl;
  return 0;
}
