#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e7;
int main(void) {
  int n, m;
  cin >> n >> m;
  int g[100][100], h[100][100];
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++) g[i][j] = INF;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a - 1][b - 1] = c;
    g[b - 1][a - 1] = c;
  }
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++) h[i][j] = g[i][j];
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      for (int k = 0; k < 100; k++) {
        g[i][j] = min(g[i][k] + g[k][j], g[i][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (h[i][j] != INF && g[i][j] != h[i][j]) ans++;
    }
  }
  cout << ans / 2 << endl;
}
