#include <bits/stdc++.h>
using ll = long long;
using namespace std;
struct edge {
  int from;
  int to;
  int cost;
};
int main() {
  int n, m;
  cin >> n >> m;
  int dist[n][n];
  vector<edge> graph;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      dist[i][j] = (1 << 30);
    }
  }
  for (int i = 0; i < n; ++i) dist[i][i] = 0;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    dist[a][b] = dist[b][a] = c;
    graph.push_back((edge){a, b, c});
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto e : graph) {
    bool flag = false;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (dist[i][e.from] + e.cost + dist[e.to][j] == dist[i][j] ||
            dist[i][e.to] + e.cost + dist[e.from][j] == dist[i][j]) {
          flag = true;
          goto endloop;
        }
      }
    }
  endloop:
    if (!flag) ++ans;
  }
  cout << ans << endl;
  return 0;
}
