#include <bits/stdc++.h>
struct edge {
  int from;
  int to;
  int cost;
};
struct edge es[2000];
int d[1000];
int n, m;
int co[100][100];
void shortest(int s) {
  int i;
  int f = 0;
  for (i = 0; i < n; i++) d[i] = 200000000;
  d[s] = 0;
  while (1) {
    f = 0;
    for (i = 0; i < m; i++) {
      struct edge e;
      e.from = es[i].from;
      e.to = es[i].to;
      e.cost = es[i].cost;
      if (d[e.from] != 200000000 && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        f = 1;
      }
      if (d[e.to] != 200000000 && d[e.from] > d[e.to] + e.cost) {
        d[e.from] = d[e.to] + e.cost;
        f = 1;
      }
    }
    if (f == 0) break;
  }
  for (i = 0; i < n; i++) {
    co[s][i] = ((co[s][i]) < (d[i]) ? (co[s][i]) : (d[i]));
    co[i][s] = co[s][i];
  }
}
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &es[i].from, &es[i].to, &es[i].cost);
    es[i].from--;
    es[i].to--;
  }
  for (i = 0; i < 100; i++) {
    for (j = 0; j < 100; j++) {
      co[i][j] = 200000000;
    }
  }
  for (i = 0; i < n; i++) shortest(i);
  int ans = m, anss[1000] = {0};
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      int k;
      for (k = 0; k < m; k++) {
        if (co[i][es[k].from] + es[k].cost == co[es[k].to][j]) anss[k] = 1;
        if (co[i][es[k].to] + es[k].cost == co[es[k].from][j]) anss[k] = 1;
      }
    }
  }
  for (i = 0; i < m; i++) {
    ans -= anss[i];
  }
  printf("%d\n", ans);
  return 0;
}
