#include <bits/stdc++.h>
using namespace std;
struct initon {
  initon() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  };
} hoee;
using ll = long long;
using vi = vector<long long>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<long long, long long>;
using T = tuple<long long, long long, long long>;
using vp = vector<P>;
using dou = double;
using itn = long long;
using str = string;
const long long INF = (long long)1e9 + 100;
const long long MINF = (long long)-1e9 - 100;
const ll LINF = (ll)1e18 + 100;
const ll MLINF = (ll)1e18 - 100;
const double EPS = 1e-9;
const long long y4[] = {-1, 1, 0, 0};
const long long x4[] = {0, 0, -1, 1};
const long long y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const long long x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
template <typename A, size_t N, typename T>
void fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
template <typename T = long long>
T in() {
  T x;
  cin >> x;
  return (x);
}
string sin() { return in<string>(); }
double din() { return in<double>(); }
ll lin() { return in<ll>(); }
template <class T>
void out(T x) {
  if (typeid(x) == typeid(double))
    cout << fixed << setprecision(10) << x << endl;
  else
    cout << x << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
inline bool inside(long long y, long long x, long long H, long long W) {
  return y >= 0 && x >= 0 && y < H && x < W;
}
ll MOD = (long long)1e9 + 7;
class mint {
 private:
  ll v;

 public:
  static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
  mint(ll a = 0) { this->v = mod(a); };
  mint(const mint &a) { v = a.v; }
  mint operator+(const mint &a) { return mint(v + a.v); }
  mint operator+(const ll a) { return mint(v + a % MOD); }
  mint operator+(const signed a) { return mint(v + a % MOD); }
  friend mint operator+(const ll a, const mint &b) {
    return mint(a % MOD + b.v);
  }
  void operator+=(const mint &a) { v = (v + a.v) % MOD; }
  void operator+=(const ll a) { v = mod(v + a % MOD); }
  void operator+=(const signed a) { v = mod(v + a % MOD); }
  friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
  mint operator-(const mint &a) { return mint(v - a.v); }
  mint operator-(const ll a) { return mint(v - a % MOD); }
  mint operator-(const signed a) { return mint(v - a % MOD); }
  friend mint operator-(const ll a, const mint &b) {
    return mint(a % MOD - b.v);
  }
  void operator-=(const mint &a) { v = mod(v - a.v); }
  void operator-=(const ll a) { v = mod(v - a % MOD); }
  void operator-=(const signed a) { v = mod(v - a % MOD); }
  friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
  mint operator*(const mint &a) { return mint(v * a.v); }
  mint operator*(const ll a) { return mint(v * (a % MOD)); }
  mint operator*(const signed a) { return mint(v * (a % MOD)); }
  friend mint operator*(const ll a, const mint &b) {
    return mint(a % MOD * b.v);
  }
  void operator*=(const mint &a) { v = (v * a.v) % MOD; }
  void operator*=(const ll a) { v = mod(v * (a % MOD)); }
  void operator*=(const signed a) { v = mod(v * (a % MOD)); }
  friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
  mint operator/(const mint &a);
  mint operator/(const ll a);
  mint operator/(const signed a);
  friend mint operator/(const ll a, const mint &b);
  void operator/=(const mint &a);
  void operator/=(const ll a);
  void operator/=(const signed a);
  friend void operator/=(ll &a, const mint &b);
  mint operator+() { return *this; }
  mint operator++() {
    v++;
    return *this;
  }
  mint operator++(signed d) {
    mint res = *this;
    v++;
    return res;
  }
  mint operator-() { return operator*(-1); }
  mint operator--() {
    v++;
    return *this;
  }
  void operator--(signed d) {
    mint res = *this;
    v++;
  }
  bool operator==(mint &a) { return v == a.v; }
  bool operator==(signed a) { return v == a; }
  friend bool operator==(signed a, mint &b) { return a == b.v; }
  bool operator!=(mint &a) { return v != a.v; }
  bool operator!=(signed a) { return v != a; }
  friend bool operator!=(signed a, mint &b) { return a != b.v; }
  operator long long() { return v; }
};
const long long setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < setModMax; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
mint minv(ll a) {
  if (a < setModMax) return inv[a];
  a %= MOD;
  ll b = MOD, x = 1, y = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    x -= t * y;
    swap(x, y);
  }
  return (x % MOD + MOD) % MOD;
}
mint mpow(mint &v, ll a) {
  ll x = v, n = a, res = 1;
  while (n) {
    if (n & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
    n >>= 1;
  }
  return res;
}
mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }
mint mint::operator/(const ll a) { return mint(v * minv(a)); }
mint mint::operator/(const signed a) { return mint(v * minv(a)); }
mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }
void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; }
void mint::operator/=(const ll a) { v = mod(v * minv(a)); }
void mint::operator/=(const signed a) { v = mod(v * minv(a)); }
void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }
mint com(ll n, ll r) {
  if (n < r || n < 0 || r < 0) return 0;
  if (fac[0] == 0) setMod();
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
ll u(ll a) { return a < 0 ? 0 : a; }
long long N, M, H, W, A[101010];
signed main() {
  cin >> N >> M;
  vvi d(101, vi(101, INF));
  long long a[101], b[101], co[101];
  for (long long i = 0; i < M; ++i) {
    cin >> a[i] >> b[i] >> co[i];
    a[i]--, b[i]--;
  }
  for (long long i = 0; i < M; ++i) {
    long long u = a[i], v = b[i], c = co[i];
    d[u][v] = d[v][u] = c;
  }
  for (long long i = 0; i < 101; ++i) {
    d[i][i] = 0;
  }
  for (long long k = 0; k < 101; ++k) {
    for (long long i = 0; i < 101; ++i) {
      for (long long j = 0; j < 101; ++j) {
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long cou = 0;
  for (long long i = 0; i < M; ++i) {
    if (co[i] != d[a[i]][b[i]]) cou++;
  }
  cout << cou << endl;
  return 0;
}
