#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
int n, m, x, y;
long long z = 0, w, h, sum = 0, ans = 0;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  std::fill((T*)array, (T*)(array + N), val);
}
struct Corr {
  long long x;
  long long y;
  long long z;
};
int main(void) {
  cin >> n >> m;
  long long dp[110][110];
  vector<Corr> a(m);
  Fill(dp, INF);
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    x--;
    y--;
    dp[x][y] = z;
    dp[y][x] = z;
    a[i] = {x, y, z};
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  for (int i = 0; i < m; i++) {
    bool f = 0;
    for (int j = 0; j < n; j++) {
      if (dp[j][a[i].x] + a[i].z == dp[j][a[i].y]) {
        f = 1;
        break;
      }
      if (dp[j][a[i].y] + a[i].z == dp[j][a[i].x]) {
        f = 1;
        break;
      }
    }
    if (!f) ans++;
  }
  cout << ans << endl;
}
