#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
const ll INF = 1e18;
const ll mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m;
  cin >> n >> m;
  vec<vec<ll>> a(n + 1, vec<ll>(n + 1, mod));
  vec<vec<ll>> path(n + 1, vec<ll>(n + 1, mod));
  vec<vec<bool>> used(n + 1, vec<bool>(n + 1, false));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) path[i][j] = i;
    a[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    a[x][y] = a[y][x] = c;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (a[i][k] + a[j][k] < a[i][j]) {
          path[i][j] = path[k][j];
          a[i][j] = a[j][i] = a[i][k] + a[j][k];
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int from = j;
      int next = path[i][j];
      while (from != i) {
        used[next][from] = true;
        from = next;
        next = path[i][next];
      }
    }
  }
  ll cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (used[i][j]) cnt++;
    }
  }
  cout << (m - (cnt / 2)) << endl;
}
