#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
using P = pair<long long, long long>;
using PP = pair<P, long long>;
using D = pair<long double, long double>;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long long modpow(long long x, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans *= x;
      if (mod <= ans) ans %= mod;
    }
    x *= x;
    if (mod <= x) x %= mod;
    n >>= 1;
  }
  return ans;
}
long long fact[1000000];
void f_init(long long n) {
  if (1000000 <= n) return;
  fact[0] = fact[1] = 1;
  for (long long i = 2; i <= n; ++i) {
    fact[i] = i * fact[i - 1];
    if (mod <= fact[i]) fact[i] %= mod;
  }
  return;
}
long long comb(long long n, long long r) {
  if (n < r) return 0;
  if (n == r) return 1;
  long long ans =
      fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
  if (ans < 0) return ans + mod;
  return ans;
}
long long nck[1010][1010];
void comb(long long n) {
  for (long long i = 0; i < (long long)(n + 1); ++i) {
    for (long long j = 0; j < (long long)(i + 1); ++j) {
      if (j == 0 || i == j)
        nck[i][j] = 1;
      else
        nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
    }
  }
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool pri(long long p) {
  for (long long i = 2; i * i <= p; ++i)
    if (p % i == 0) return false;
  return p > 1;
}
map<long long, long long> factring(long long n) {
  map<long long, long long> ans;
  for (long long i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      n /= i;
      ++ans[i];
    }
  }
  if (n != 1) ++ans[n];
  return ans;
}
long long n, m;
long long a[101], b[101], c[101];
long long d[101][101];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < (long long)(n); ++i) {
    for (long long j = 0; j < (long long)(n); ++j) {
      if (i != j) d[i][j] = inf;
    }
  }
  for (long long i = 0; i < (long long)(m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  for (long long k = 0; k < (long long)(n); ++k) {
    for (long long i = 0; i < (long long)(n); ++i) {
      for (long long j = 0; j < (long long)(n); ++j) {
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long ans = m;
  for (long long i = 0; i < (long long)(m); ++i) {
    for (long long j = 0; j < (long long)(n); ++j) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) {
        --ans;
        break;
      }
    }
  }
  cout << ans << endl;
}
