#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
vi to[104];
int dp[104][104];
int n, m;
int main() {
  cin >> n >> m;
  vector<pair<ii, int>> edges(m);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (n); ++j) {
      dp[i][j] = INF;
      dp[i][i] = 0;
    }
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dp[a][b] = c;
    dp[b][a] = c;
    to[a].push_back(b);
    to[b].push_back(a);
    edges[i] = {ii(a, b), c};
  }
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  vector<bool> used(m, false);
  for (int s = 0; s < (n); ++s) {
    for (int i = 0; i < (m); ++i) {
      int k = edges[i].first.first;
      int t = edges[i].first.second;
      if (s == k || s == t) continue;
      if (dp[s][k] > dp[s][t]) swap(k, t);
      if (dp[s][t] == dp[s][k] + dp[k][t]) used[i] = true;
    }
  }
  ll ans = 0;
  for (int i = 0; i < (m); ++i)
    if (!used[i]) ans++;
  cout << ans << endl;
  return 0;
}
