#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k;
int a[100][100];
int cost[100][100];
bool flg[100][100];
int main() {
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      a[i][j] = 10000000;
      cost[i][j] = 10000000;
      if (i == j) cost[i][i] = 0;
    }
  }
  for (i = 0; i < m; i++) {
    int t0, t1, t2;
    scanf("%d %d %d", &t0, &t1, &t2);
    t0--, t1--;
    a[t0][t1] = t2;
    a[t1][t0] = t2;
    cost[t0][t1] = t2;
    cost[t1][t0] = t2;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < n; k++) {
        if (cost[j][k] > cost[j][i] + a[i][k]) {
          cost[j][k] = cost[j][i] + a[i][k];
        }
      }
    }
  }
  int ans = 2 * m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k < n; k++) {
        if (j != k && cost[i][j] + a[j][k] == cost[i][k]) {
          flg[j][k] = true;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (flg[i][j]) ans--;
    }
  }
  printf("%d\n", ans / 2);
}
