#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 110;
const int INF = 1e7;
const int MOD = 1e9 + 7;
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dist[MAX][MAX];
bool used[MAX][MAX];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = (i == j ? 0 : INF);
    }
  }
  int a[M], b[M], c[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = dist[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++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < M; k++) {
      if (dist[i][a[k]] + c[i] == dist[i][b[k]]) {
        used[a[k]][b[k]] = true;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++)
    if (!used[a[i]][b[i]]) {
      ans++;
    }
  cout << ans << endl;
  return 0;
}
