#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int dp[2][5001][2];
template <typename T>
T debug(T x) {
  cout << "x"
       << ": " << x << "\n";
  return x;
}
int d[100][100];
int dd[100][100];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF;
    }
  }
  vector<tiii> e;
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    e.push_back(tiii{a, b, c});
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < (n); ++k) {
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (n); ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (n); ++j) {
    }
  }
  int ans = 0;
  for (int l = 0; l < (m); ++l) {
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (n); ++j) {
        if (i == j)
          dd[i][j] = 0;
        else
          dd[i][j] = INF;
      }
    }
    for (int p = 0; p < (m); ++p) {
      if (l == p) continue;
      int a = get<0>(e[p]), b = get<1>(e[p]), c = get<2>(e[p]);
      dd[a][b] = c;
      dd[b][a] = c;
    }
    for (int k = 0; k < (n); ++k) {
      for (int i = 0; i < (n); ++i) {
        for (int j = 0; j < (n); ++j) {
          dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
        }
      }
    }
    bool needed = false;
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (n); ++j) {
        if (d[i][j] != dd[i][j]) needed = true;
      }
    }
    ans += needed;
  }
  cout << m - ans << "\n";
  return 0;
}
