#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline void init() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int N, M;
  cin >> N >> M;
  vector<vector<int>> d(N, vector<int>(N, INF));
  for (int(i) = (0); (i) < (N); ++(i)) d[i][i] = 0;
  vector<pair<int, int>> edge;
  vector<int> cost;
  for (int(i) = (0); (i) < (M); ++(i)) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    d[a][b] = c;
    d[b][a] = c;
    edge.push_back({a, b});
    cost.push_back(c);
  }
  for (int(i) = (0); (i) < (N); ++(i)) {
    for (int(j) = (0); (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 = M;
  for (int(i) = (0); (i) < (M); ++(i)) {
    bool ok = false;
    for (int(j) = (0); (j) < (N); ++(j)) {
      int x = edge[i].first, y = edge[i].second;
      if (d[j][x] + cost[i] == d[j][y]) ok = true;
    }
    if (ok) ans--;
  }
  cout << ans << "\n";
  return 0;
}
