#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int MAX = 2 * 100 + 10;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
long long d[MAX][MAX];
vector<vector<long long> > edges;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  for (long long i = 0; i < MAX; i++) {
    for (long long j = 0; j < MAX; j++) d[i][j] = INF;
    d[i][i] = 0;
  }
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    edges.push_back({x, y, w});
    d[x][y] = d[y][x] = w;
  }
  for (long long k = 1; k <= n; ++k) {
    for (long long i = 1; i <= n; ++i) {
      for (long long j = 1; j <= n; ++j) {
        if (d[i][k] < INF && d[k][j] < INF)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  long long ans(0);
  for (auto g : edges) {
    long long x = g[0], y = g[1], w = g[2];
    long long f = 1;
    for (long long i = 1; i <= n; i++)
      for (long long j = i + 1; j <= n; j++) {
        if (d[i][j] == (d[i][x] + d[j][y] + w)) f = 0;
      }
    ans += f;
  }
  cout << ans << '\n';
}
