#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m[105][105];
  for (int i = 0; i < 105; i++) {
    for (int r = 0; r < 105; r++) {
      if (i == r) {
        m[i][i] = 0;
      } else {
        m[i][r] = 1000000000000LL;
      }
    }
  }
  long long n, q;
  cin >> n >> q;
  vector<pair<long long, pair<long long, long long> > > v;
  for (int i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    long long c;
    cin >> c;
    m[a][b] = c;
    m[b][a] = c;
    v.push_back(make_pair(c, make_pair(a, b)));
  }
  sort((v).begin(), (v).end());
  reverse((v).begin(), (v).end());
  long long d[105][105];
  memset((d), (0), sizeof(d));
  for (int k = 0; k < 105; k++) {
    for (int i = 0; i < 105; i++) {
      for (int j = 0; j < 105; j++) {
        if (m[i][j] > m[i][k] + m[k][j]) {
          d[i][k] = 1;
          d[k][j] = 1;
          m[i][j] = m[i][k] + m[k][j];
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = (0); i < (v.size()); ++i) {
    if (d[v[i].second.first][v[i].second.second] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
