#include <bits/stdc++.h>
using namespace std;
long long int N, M, i, j, k, a, b, c;
long long int d[100][100], t[100][100];
vector<pair<long long int, long long int> > w;
bool u[1000];
int main() {
  scanf("%lld%lld", &N, &M);
  for (i = 0; i < N; ++i) {
    for (j = 0; j < N; ++j) {
      d[i][j] = 2147483647;
      t[i][j] = j;
    }
    d[i][i] = 0;
  }
  for (i = 0; i < M; ++i) {
    scanf("%lld%lld%lld", &a, &b, &c);
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
    w.push_back(make_pair(min(a, b) - 1, max(a, b) - 1));
  }
  for (k = 0; k < N; ++k) {
    for (i = 0; i < N; ++i) {
      for (j = 0; j < N; ++j) {
        if (d[i][k] + d[k][j] < d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
          t[i][j] = t[i][k];
        }
      }
    }
  }
  vector<pair<long long int, long long int> >::iterator y, z, be = w.begin(),
                                                              en = w.end();
  for (i = 0; i < N; ++i) {
    for (j = 0; j < N; ++j) {
      y = upper_bound(be, en, make_pair(min(i, t[i][j]), max(i, t[i][j])));
      z = lower_bound(be, en, make_pair(min(i, t[i][j]), max(i, t[i][j])));
      if (z - y != 0) u[y - be] = true;
    }
  }
  cout << count(u, u + M, false) << endl;
  return 0;
}
