#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8 + 10;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> g(N + 1, vector<int>(N + 1, INF));
  vector<tuple<int, int, int>> E;
  while (M--) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x][y] = z;
    g[y][x] = z;
    E.push_back({x, y, z});
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 1; k <= N; k++) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto [x, y, z] : E) {
    if (g[x][y] != z) ans++;
  }
  cout << ans << '\n';
  return 0;
}
