#include <bits/stdc++.h>
using namespace std;
long long modpow(long long x, long long y,
                 long long m = (long long)(1000000007)) {
  long long res = 1;
  while (y) {
    if (y % 2) {
      res *= x;
      res %= m;
    }
    x = x * x % (long long)(1000000007);
    y /= 2;
  }
  return res;
}
bool prime(long long x) {
  for (long long i = 2; i <= sqrt(x); i++) {
    if (!(x % i)) {
      return false;
    }
  }
  return true;
}
double kyori(pair<long long, long long> f, pair<long long, long long> s) {
  double ans = 0;
  double t = fabs(f.first - s.first);
  double y = fabs(f.second - s.second);
  ans = sqrt(t * t + y * y);
  return ans;
}
long long gcd(long long x, long long y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}
string s;
long long n, m;
long long kyo[104][104], sai[104][104], nex[104][104], ans;
bool used[104][104];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    kyo[a][b] = c;
    kyo[b][a] = c;
    sai[a][b] = c;
    sai[b][a] = c;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (!sai[i][j]) {
        sai[i][j] = (long long)(3e18);
        kyo[i][j] = (long long)(3e18);
      }
      nex[i][j] = j;
    }
  }
  for (long long i = 1; i <= n - 1; i++) {
    for (long long j = i + 1; j <= n; j++) {
      for (long long k = 1; k <= n; k++) {
        if (sai[i][j] > sai[i][k] + sai[k][j]) {
          nex[i][j] = nex[i][k];
          sai[i][j] = sai[i][k] + sai[k][j];
        }
      }
    }
  }
  for (long long i = 1; i <= n - 1; i++) {
    for (long long j = i + 1; j <= n; j++) {
      if (!used[min(i, nex[i][j])][max(i, nex[i][j])]) {
        ans++;
      }
      used[min(i, nex[i][j])][max(i, nex[i][j])] = true;
    }
  }
  cout << m - ans << endl;
}
