#include <bits/stdc++.h>
using namespace std;
void print(const vector<vector<int>>& xs, int N) {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cout << xs[i][j] << ", ";
    }
    cout << endl;
  }
  cout << endl;
}
int main() {
  int N, M;
  cin >> N >> M;
  constexpr int INF = numeric_limits<int>::max();
  vector<vector<int>> es(N, vector<int>(N, 0x3f3f3f3f));
  vector<pair<int, int>> es_list;
  for (int i = 1; i <= M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    es[a][b] = c;
    es[b][a] = c;
    es_list.push_back(make_pair(a, b));
  }
  auto ds = es;
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (ds[i][j] > ds[i][k] + ds[k][j]) {
          ds[i][j] = ds[i][k] + ds[k][j];
        }
      }
    }
  }
  int ans = 0;
  for (const auto& edge : es_list) {
    int i = edge.first;
    int j = edge.second;
    bool used = false;
    for (int s = 0; s < N; ++s) {
      if (ds[s][i] + es[i][j] == ds[s][j]) used = true;
    }
    if (!used) ++ans;
  }
  cout << ans << endl;
}
