#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
int inf = 1e9;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  int a, b, c;
  vvi d(n, vi(n, inf));
  vvi used(n, vi(n, 0)), e(n, vi(n, -1));
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = d[b][a] = c;
    e[a][b] = e[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int last = 0; last < n; last++) {
        if (e[last][j] > 0 && d[i][j] == d[i][last] + e[last][j]) {
          used[last][j] = used[j][last] = 1;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (e[i][j] > 0 && !used[i][j]) ans++;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
