#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2 - 100;
const int NEG_INF = numeric_limits<int>::min() / 2;
int N, M;
const int MAX_N = 100 + 10;
int d[MAX_N][MAX_N];
struct edge {
  int u, v, cost;
};
vector<edge> edges;
void solve() {
  for (int i = 0; i < (MAX_N); i++) {
    for (int j = 0; j < (MAX_N); j++) {
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }
  for (auto e : edges) {
    d[e.u][e.v] = e.cost;
    d[e.v][e.u] = e.cost;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      for (int k = 0; k <= N; k++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto e : edges) {
    bool flg = false;
    for (int u = 1; u <= N; u++) {
      for (int v = 1; v <= N; v++) {
        if (d[u][v] == d[u][e.u] + e.cost + d[e.v][v]) {
          flg = true;
          break;
        }
      }
    }
    if (!flg) {
      ans += 1;
    }
  }
  cout << ans << endl;
}
int main(int argc, char const* argv[]) {
  cin >> N >> M;
  for (int i = 0; i < (M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    edges.push_back({a, b, c});
  }
  solve();
  return 0;
}
