#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int n, m, a, b, c, v[105][105], i, j, k, ans = 0;
  for (i = 0; i < 105; i++) {
    for (j = 0; j < 105; j++) {
      v[i][j] = INF;
    }
  }
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    v[a][b] = c;
    v[b][a] = c;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < n; k++) {
        if (v[j][k] != INF) {
          if (v[j][k] > v[j][i] + v[i][k]) {
            v[j][k] = v[j][i] + v[i][k];
            ans++;
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
}
