#include <bits/stdc++.h>
using namespace std;
int N, M;
const int INF = 1LL << 55;
int main() {
  cin >> N >> M;
  int g[101][101], h[101][101];
  fill(g[0], g[101], INF);
  fill(h[0], h[101], INF);
  for (int i = 0; i < 101; i++) g[i][i] = h[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = g[b][a] = h[a][b] = h[b][a] = c;
  }
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++) g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (h[i][j] == INF) continue;
      if (g[i][j] != h[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
