#include <bits/stdc++.h>
using namespace std;
const int OO = 1000000000;
int g[105][105];
int a[105], b[105], c[105];
void init() {
  for (int i = 0; i < 105; ++i)
    for (int j = 0; j < 105; ++j)
      if (i == j)
        g[i][j] = 0;
      else
        g[i][j] = g[j][i] = OO;
  for (int i = 0; i < 105; ++i) a[i] = b[i] = c[i] = 0;
}
int main() {
  init();
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    g[a[i]][b[i]] = min(c[i], g[a[i]][b[i]]);
    g[b[i]][a[i]] = min(c[i], g[b[i]][a[i]]);
  }
  for (int k = 0; k < n; ++k)
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  int cnt = m;
  for (int i = 0; i < m; ++i) {
    bool is = false;
    for (int j = 0; j < n; ++j)
      if (g[j][b[i]] == g[j][a[i]] + c[i]) is = true;
    if (is) --cnt;
  }
  cout << cnt;
  return 0;
}
