#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[100], B[100];
int C[100][100];
int mincost[100][100];
bool done[100];
void solve() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      done[j] = false;
      mincost[i][j] = 1010101010;
    }
    mincost[i][i] = 0;
    while (true) {
      int mj = 0;
      int mc = 1010101010;
      for (int j = 0; j < N; j++) {
        if (!done[j] && mc > mincost[i][j]) {
          mj = j;
          mc = mincost[i][j];
        }
      }
      if (mc == 1010101010) break;
      done[mj] = true;
      for (int j = 0; j < N; j++) {
        if (mincost[i][mj] + C[mj][j] < mincost[i][j])
          mincost[i][j] = mincost[i][mj] + C[mj][j];
      }
    }
  }
  int ans = M;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      if (mincost[j][A[i]] + C[A[i]][B[i]] == mincost[j][B[i]]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      C[i][j] = C[i][j] = 1010101010;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> A[i] >> B[i] >> c;
    A[i]--;
    B[i]--;
    C[A[i]][B[i]] = C[B[i]][A[i]] = c;
  }
  solve();
}
