#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
struct Edge {
  int from, to, cost;
};
int main() {
  int n, m;
  cin >> n >> m;
  int dist[110][110] = {};
  vector<Edge> es(m);
  for (int i = 0; i < m; ++i) {
    cin >> es[i].from >> es[i].to >> es[i].cost;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = INF;
    }
  }
  for (int i = 0; i < m; ++i) {
    dist[es[i].from][es[i].to] = min(dist[es[i].from][es[i].to], es[i].cost);
    dist[es[i].to][es[i].from] = min(dist[es[i].to][es[i].from], es[i].cost);
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; ++i) {
    bool shortest = false;
    for (int j = 1; j <= n; ++j) {
      if (dist[j][es[i].from] + es[i].cost == dist[j][es[i].to])
        shortest = true;
    }
    if (shortest) ans--;
  }
  cout << ans << endl;
  return 0;
}
