#include <bits/stdc++.h>
using namespace std;
using Pll = pair<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> dist(N, vector<long long>(N, INF));
  vector<long long> A(N), B(N), C(N);
  for (int i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        dist[i][j] = 0;
      else {
        dist[A[i]][B[i]] = min(dist[A[i]][B[i]], C[i]);
        dist[B[i]][A[i]] = min(dist[A[i]][B[i]], C[i]);
      }
    }
  }
  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]);
      }
    }
  }
  long long ans = M;
  for (int i = 0; i < M; i++) {
    bool shortest = false;
    for (int s = 0; s < N; s++) {
      for (int t = 0; t < N; t++) {
        if (dist[s][t] == dist[s][A[i]] + dist[B[i]][t] + C[i]) {
          shortest = true;
        }
      }
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
  return 0;
}
