#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int INF = 1005;
int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> G;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G.push_back({a, b, c});
    G.push_back({b, a, c});
  }
  int used[n + 1][n + 1], done[n + 1][n + 1];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) used[i][j] = done[i][j] = 0;
  for (int s = 1; s <= n; s++) {
    vector<int> dis(n + 1, INF), par(n + 1);
    dis[s] = 0;
    for (int i = 1; i <= n - 1; i++) {
      bool red = false;
      for (int j = 0; j < 2 * m; j++) {
        int u, v, w;
        tie(u, v, w) = G[j];
        if (dis[v] > dis[u] + w) {
          dis[v] = dis[u] + w;
          par[v] = u;
          red = true;
        }
      }
      if (!red) break;
    }
    for (int i = 1; i <= n; i++) {
      if (i == s) continue;
      if (!done[i][s]) {
        done[s][i] = 1;
        int ii = i;
        while (ii != s) {
          used[ii][par[ii]] = used[par[ii]][ii] = 1;
          ii = par[ii];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 2 * m; i += 2) {
    int u, v, w;
    tie(u, v, w) = G[i];
    if (!used[u][v]) {
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}
