#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
long long factorial(long long n) {
  long long t = 1;
  for (long long(i) = 1; (i) <= (n); ++(i)) t *= i;
  return t;
}
long long combinations(long long n, long long k) {
  long long r = 1;
  for (long long(i) = 1; (i) <= (k); ++(i)) r = r * n-- / i;
  return r;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(m), b(m), c(m);
  long long g[n][n];
  for (long long(i) = 0; (i) < (n); ++(i))
    for (long long(j) = 0; (j) < (n); ++(j)) {
      if (i == j)
        g[i][j] = 0;
      else
        g[i][j] = (1e9);
      ;
    }
  for (long long(i) = 0; (i) < (m); ++(i)) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    g[a[i]][b[i]] = min(g[a[i]][b[i]], c[i]);
    g[b[i]][a[i]] = min(g[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 (g[i][k] + g[k][j] < g[i][j]) g[i][j] = g[i][k] + g[k][j];
  long long ans = m;
  for (long long(i) = 0; (i) < (m); ++(i)) {
    bool f = false;
    for (long long(j) = 0; (j) < (m); ++(j))
      if (g[j][a[i]] + c[i] == g[j][b[i]]) f = true;
    if (f) --ans;
  }
  cout << (ans) << endl;
  return 0;
}
