#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int N, M;
int a[1010], b[1010], c[1010];
int dis[110][110];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int flag = 1;
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (dis[j][k] == dis[j][a[i]] + dis[b[i]][k] + c[i]) {
          flag = 0;
        }
      }
    }
    ans += flag;
  }
  cout << ans << endl;
  return 0;
}
