#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long d[100][100];
long long pre[100][100];
set<pair<long long, long long> > x;
void path(long long start, long long goal) {
  long long cur;
  for (cur = goal; cur != start; cur = pre[start][cur]) {
    x.insert(pair<long long, long long>(min(cur, pre[start][cur]),
                                        max(cur, pre[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++) {
    for (long long j = 0; j < (N); j++) {
      pre[i][j] = i;
    }
  }
  for (long long i = 0; i < (N); i++) {
    for (long long j = i + 1; j < N; ++j) {
      for (long long k = 0; k < (N); k++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          pre[i][j] = pre[k][j];
        }
      }
    }
  }
  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;
}
