#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long d[100][100];
set<long long> pre[100][100];
set<pair<long long, long long> > x;
void path(long long start, long long goal) {
  for (auto it = pre[start][goal].begin(); it != pre[start][goal].end(); ++it) {
    long long cur = *it;
    x.insert(pair<long long, long long>(min(goal, cur), max(goal, cur)));
    if (cur == start) return;
    path(start, cur);
  }
}
signed main() {
  cin >> N >> M;
  for (long long i = 0; i < (100); i++) {
    fill(d[i], d[i] + 100, (1ll << 60));
    d[i][i] = 0;
  }
  for (long long i = 0; i < (M); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (long long i = 0; i < (N); i++) {
    fill(pre[i], pre[i] + 100, set<long long>{i});
  }
  for (long long i = 0; i < (N); i++) {
    for (long long j = 0; j < (N); j++) {
      for (long long k = 0; k < (N); k++) {
        if (i == k || k == j) continue;
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          pre[i][j].clear();
          pre[i][j].insert(pre[k][j].begin(), pre[k][j].end());
        } else if (d[i][j] == d[i][k] + d[k][j]) {
          pre[i][j].insert(pre[k][j].begin(), pre[k][j].end());
        }
      }
    }
  }
  for (long long i = 0; i < (N); i++) {
    for (long long j = i + 1; j < N; ++j) {
      if (d[i][j] < 99999999999) {
        path(i, j);
      }
    }
  }
  cout << M - x.size() << endl;
}
