#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
const int NMAX = 120;
int n, m;
bool rinsetsu[NMAX][NMAX];
int d[NMAX][NMAX];
int previous[NMAX][NMAX];
void WF() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          previous[i][j] = previous[k][j];
        }
      }
    }
  }
}
void delete_path(int start, int goal) {
  vector<int> path;
  int via = 0, current;
  for (current = goal; current != start; current = previous[start][current]) {
    path.push_back(current);
  }
  path.push_back(start);
  for (int i = 0; i < path.size() - 1; i++) {
    rinsetsu[path[i]][path[i + 1]] = rinsetsu[path[i + 1]][path[i]] = false;
  }
}
void debug() {
  printf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) printf("%d ", d[i][j]);
    printf("\n");
  }
  printf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) printf("%d ", previous[i][j]);
    printf("\n");
  }
  printf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) printf("%d ", rinsetsu[i][j]);
    printf("\n");
  }
  printf("\n");
}
void initializer() {
  memset(d, INF, sizeof(d));
  memset(rinsetsu, false, sizeof(rinsetsu));
  for (int i = 0; i < NMAX; i++) d[i][i] = 0;
  for (int i = 0; i < NMAX; i++) {
    for (int j = 0; j < NMAX; j++) previous[i][j] = i;
  }
}
signed main() {
  initializer();
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int tmp1, tmp2, tmp3;
    scanf("%d%d%d", &tmp1, &tmp2, &tmp3);
    tmp1--;
    tmp2--;
    rinsetsu[tmp1][tmp2] = rinsetsu[tmp2][tmp1] = true;
    d[tmp1][tmp2] = d[tmp2][tmp1] = tmp3;
  }
  WF();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) delete_path(i, j);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (rinsetsu[i][j]) ans++;
    }
  }
  printf("%d\n", ans / 2);
}
