#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long digitsum(long long n, long long b) {
  if (b < 2) return -1;
  if (n < b) return n;
  return digitsum(n / b, b) + n % b;
}
long long mpow(long long a, long long x);
long long m_inv(long long n);
vector<long long> split(long long n, long long a);
string xal_number(long long n, long long x);
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
class Factorial {
 private:
  vector<long long> fac;

 public:
  Factorial(long long N) {
    fac.push_back(1);
    for (long long i = (0); i < (N); ++i) fac.push_back(fac[i] * (i + 1) % mod);
  }
  long long fact(long long a) { return fac[a]; }
  long long ifac(long long a) { return m_inv(fac[a]); }
  long long cmb(long long n, long long r);
};
struct UnionFind {
  vector<long long> par;
  UnionFind(long long n = 1) { init(n); }
  void init(long long n = 1) {
    par.resize(n);
    for (long long i = (0); i < (n); ++i) par[i] = -1;
  }
  long long root(long long x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }
  long long size(long long x) { return -par[root(x)]; }
  bool issame(long long x, long long y) { return root(x) == root(y); }
  bool connect(long long x, long long y);
};
signed main() {
  long long N, M;
  cin >> N >> M;
  long long INF = 1 << 29;
  vector<long long> a(M), b(M), c(M);
  vector<vector<long long>> dist(N, vector<long long>(N, INF));
  for (long long i = (0); i < (M); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (long long k = (0); k < (N); ++k)
    for (long long i = (0); i < (N); ++i)
      for (long long j = (0); j < (N); ++j) {
        if (dist[i][j] > dist[i][k] + dist[k][j])
          dist[i][j] = dist[i][k] + dist[k][j];
      }
  long long ans = M;
  for (long long i = (0); i < (M); ++i) {
    bool shortest = false;
    for (long long j = (0); j < (N); ++j)
      if (dist[j][a[i]] + c[i] == dist[j][b[i]]) shortest = true;
    if (shortest) ans--;
  }
  cout << ans << endl;
}
