#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
static const double pi = 3.141592653589793;
int A[109], B[109], C[109];
int G[109][109];
void warshallFloyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (G[i][k] == INF) continue;
      for (int j = 0; j < n; j++) {
        if (G[k][j] == INF) continue;
        if (G[i][j] > G[i][k] + G[k][j]) G[i][j] = G[i][k] + G[k][j];
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (int i = 0; i < 109; i++)
    for (int j = 0; j < 109; j++) G[i][j] = INF;
  for (int i = 0; i < 109; i++) G[i][i] = 0;
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> A[i] >> B[i] >> C[i];
  for (int i = 0; i < M; i++) {
    G[--A[i]][--B[i]] = C[i];
    G[B[i]][A[i]] = C[i];
  }
  warshallFloyd(N);
  int cnt = 0;
  for (int i = 0; i < M; i++) {
    if (G[A[i]][B[i]] < C[i]) cnt++;
  }
  cout << cnt << endl;
}
