#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (int i = 0; i < ((int)v.size()); ++i) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename T, size_t S>
void printArray(const T (&array)[S]) {
  for (auto val : array) std::cout << val << ", ";
  std::cout << "\n";
}
const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  int n, m;
  std::cin >> n >> m;
  vvi to(n, vi(n, inf));
  vi a(m), b(m), c(m);
  for (int i = 0; i < (n); ++i) to[i][i] = 0;
  for (int i = 0; i < (m); ++i) {
    std::cin >> a[i] >> b[i] >> c[i];
    --a[i], --b[i];
    to[a[i]][b[i]] = to[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j)
        (to[i][j] = min(to[i][j], to[i][k] + to[k][j]));
  int ans = 0;
  for (int k = 0; k < (m); ++k) {
    bool ok = false;
    for (int i = 0; i < (n); ++i)
      for (int j = i + 1; j < n; ++j) {
        if (to[i][a[k]] + c[k] + to[b[k]][j] == to[i][j]) ok = true;
      }
    if (!ok) ans++;
  }
  std::cout << ans << "\n";
}
