#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int edge[n][n];
  int warshall_floyd[n][n];
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(n); ++j) {
      edge[i][j] = inf;
      warshall_floyd[i][j] = inf;
      if (i == j) {
        edge[i][j] = 0;
        warshall_floyd[i][j] = 0;
      }
    }
  for (int i = (int)(0); i < (int)(m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a][b] = c;
    edge[b][a] = c;
    warshall_floyd[a][b] = c;
    warshall_floyd[b][a] = c;
  }
  for (int i = (int)(0); i < (int)(n); ++i) {
    for (int j = (int)(0); j < (int)(n); ++j) {
      for (int w = (int)(0); w < (int)(n); ++w) {
        warshall_floyd[i][j] = min(warshall_floyd[i][j],
                                   warshall_floyd[i][w] + warshall_floyd[w][j]);
      }
    }
  }
  int ans = 0;
  for (int i = (int)(0); i < (int)(n - 1); ++i)
    for (int j = (int)(i + 1); j < (int)(n); ++j) {
      if (edge[i][j] != warshall_floyd[i][j] && edge[i][j] != inf) {
        ans++;
      }
    }
  cout << ans << endl;
}
