#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> used(N);
  vector<vector<int>> G(N, vector<int>(N, inf));
  for (int i = 0; i < N; i++) G[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    G[a - 1][b - 1] = c;
    G[b - 1][a - 1] = c;
    used[a - 1].push_back(make_pair(b - 1, c));
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (G[i][j] > G[i][k] + G[k][j]) {
          G[i][j] = G[i][k] + G[k][j];
        }
      }
    }
  }
  int ans = M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < used[i].size(); j++) {
      int a = i, b = used[i][j].first, c = used[i][j].second;
      bool use = false;
      for (int k = 0; k < N; k++) {
        int s = k;
        if (G[s][b] == G[s][a] + c) use = true;
      }
      if (use) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
