#include <bits/stdc++.h>
using namespace std;
const long long inf = 999999999999999999;
struct P {
  long long pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  long long to, cost;
};
struct S {
  long long from, to, cost;
};
long long gcm(long long i, long long j) {
  if (i > j) swap(i, j);
  if (i == 0) return j;
  return gcm(j % i, i);
}
long long n, m;
long long a[101][101];
S b[5000];
signed main() {
  cin >> n >> m;
  for (long long i = 0; i < (long long)(101); i++)
    for (long long j = 0; j < (long long)(101); j++) a[i][j] = inf;
  for (long long i = 0; i <= 101; i++) a[i][i] = 0;
  for (long long i = 0; i < m; i++) {
    cin >> b[i].from >> b[i].to >> b[i].cost;
    a[b[i].from][b[i].to] = b[i].cost;
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      for (long long k = 1; k <= n; k++) {
        a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
        a[j][i] = a[i][j];
      }
    }
  }
  long long sum = 0;
  for (long long i = 0; i < m; i++) {
    bool l = 1;
    for (long long j = 1; j <= n; j++)
      if (a[b[i].from][j] + b[i].cost == a[b[i].to][j]) l = 0;
    if (l) sum++;
  }
  cout << sum << endl;
  getchar();
  getchar();
}
