#include <bits/stdc++.h>
using namespace std;
int ver[105][105];
int main() {
  memset(ver, 0x3f, sizeof ver);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    ver[a][b] = c;
    ver[b][a] = c;
  }
  int mindis = 1e9;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; ++j) {
        ver[i][j] = min(ver[i][j], ver[i][k] + ver[k][j]);
        mindis = min(mindis, ver[i][j]);
      }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (ver[i][j] == mindis) ++cnt;
    }
  printf("%d", m - cnt / 2);
  return 0;
}
