#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> dist(N, vector<int>(N, INF));
  vector<int> A(M), B(M), C(M);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    A[i] = a;
    B[i] = b;
    C[i] = c;
    dist[a][b] = dist[b][a] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int res = M;
  for (int i = 0; i < M; i++) {
    bool flag = false;
    for (int j = 0; j < N; j++) {
      if (dist[j][A[i]] + C[i] == dist[j][B[i]]) {
        flag = true;
      }
    }
    if (flag) res--;
  }
  cout << res << endl;
  return 0;
}
