#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int i, j, k, n, m, ans = 0;
  scanf("%d%d", &n, &m);
  pair<pair<int, int>, int> a[m];
  bool flg[m];
  int dis[n][n];
  for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j) dis[i][j] = 1e9;
  for (i = 0; i < n; ++i) dis[i][i] = 0;
  for (i = 0; i < m; ++i) {
    scanf("%d%d%d", &a[i].first, &a[i].first.second, &a[i].second);
    a[i].first.first--, a[i].first.second--;
    dis[a[i].first.first][a[i].first.second] =
        dis[a[i].first.second][a[i].first.first] = a[i].second;
  }
  for (i = 0; i < m; ++i) flg[i] = true;
  for (k = 0; k < n; ++k)
    for (i = 0; i < n; ++i)
      for (j = 0; j < n; ++j)
        if (dis[i][j] > dis[i][k] + dis[k][j])
          dis[i][j] = dis[i][k] + dis[k][j];
  for (i = 0; i < m; ++i)
    for (j = 0; j < m; ++j) {
      if (a[i].first.first == a[j].first.first &&
          dis[a[i].first.second][a[j].first.second] ==
              a[i].second + a[j].second)
        flg[i] = flg[j] = false;
      if (a[i].first.second == a[j].first.first &&
          dis[a[i].first.first][a[j].first.second] == a[i].second + a[j].second)
        flg[i] = flg[j] = false;
      if (a[i].first.first == a[j].first.second &&
          dis[a[i].first.second][a[j].first.first] == a[i].second + a[j].second)
        flg[i] = flg[j] = false;
      if (a[i].first.second == a[j].first.second &&
          dis[a[i].first.first][a[j].first.first] == a[i].second + a[j].second)
        flg[i] = flg[j] = false;
    }
  for (i = 0; i < m; ++i)
    if (flg[i]) ++ans;
  printf("%d", ans);
  return 0;
}
