#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from;
  int to;
  int cost;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int64_t path[1001][1001];
  for (int i = 0; i < 1001; ++i) {
    for (int j = 0; j < 1001; ++j) {
      path[i][j] = 1000;
    }
  }
  vector<edge> edges(m);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edges[i] = edge{a, b, c};
    path[a][b] = c;
    path[b][a] = c;
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int k = 0; k < m; ++k) {
        path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto &e : edges) {
    if (path[e.from][e.to] < e.cost) {
      ++ans;
    }
  }
  cout << ans << "\n";
}
