#include <bits/stdc++.h>
using namespace std;
int N, M;
int D[100][100];
int E[1000][3];
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      D[i][j] = 1e8;
    }
  }
  for (int i = 0; i < N; i++) {
    D[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    D[a][b] = min(D[a][b], c);
    D[b][a] = min(D[b][a], c);
    E[i][0] = a;
    E[i][1] = b;
    E[i][2] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int a = E[i][0];
    int b = E[i][1];
    int c = E[i][2];
    if (D[a][b] != c) ans++;
  }
  cout << ans << endl;
}
