#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n, -1));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = c;
    g[b][a] = c;
  }
  vector<vector<int>> og = g;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (g[i][k] >= 0 && g[k][j] >= 0) {
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (og[i][j] >= 0 && og[i][j] > g[i][j]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
