#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<pair<int, int>, int> > v(m);
  for (int i = 0; i < (m); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    v[i] = make_pair(pair<int, int>(a, b), c);
  }
  int D[n][n];
  fill_n(*D, n * n, (int)(1e9 + 7));
  for (int i = 0; i < (n); ++i) D[i][i] = 0;
  for (int j = 0; j < (m); ++j) {
    D[v[j].first.first][v[j].first.second] = v[j].second;
    D[v[j].first.second][v[j].first.first] = v[j].second;
  }
  for (int k = 0; k < (n); ++k)
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (n); ++j) {
        if (D[i][k] + D[k][j] < D[i][j]) D[i][j] = D[i][k] + D[k][j];
      }
  int cnt = 0;
  for (int l = 0; l < (m); ++l) {
    int d[n][n];
    fill_n(*d, n * n, (int)(1e9 + 7));
    for (int i = 0; i < (n); ++i) d[i][i] = 0;
    for (int j = 0; j < (m); ++j) {
      if (l == j) continue;
      d[v[j].first.first][v[j].first.second] = v[j].second;
      d[v[j].first.second][v[j].first.first] = v[j].second;
    }
    for (int k = 0; k < (n); ++k)
      for (int i = 0; i < (n); ++i)
        for (int j = 0; j < (n); ++j) {
          if (d[i][k] + d[k][j] < d[i][j]) d[i][j] = d[i][k] + d[k][j];
        }
    int flg = 0;
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (n); ++j) {
        if (D[i][j] != d[i][j]) {
          flg = 1;
          break;
        }
      }
      if (flg) break;
    }
    if (flg == 0) cnt++;
  }
  cout << cnt << endl;
}
