#include <bits/stdc++.h>
using namespace std;
int path[101][101];
void solve(void) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= n - 1; j++) path[i][j] = (int)1e5;
  int as[m], bs[m], cs[m];
  for (int i = 0; i <= m - 1; i++) {
    scanf("%d%d%d\n", &as[i], &bs[i], &cs[i]);
    as[i]--;
    bs[i]--;
    path[as[i]][bs[i]] = path[bs[i]][as[i]] = cs[i];
  }
  for (int k = 0; k <= n - 1; k++)
    for (int i = 0; i <= n - 1; i++)
      for (int j = 0; j <= n - 1; j++)
        path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
  int ans = 0;
  for (int k = 0; k <= m - 1; k++) {
    bool flag = false;
    for (int i = 0; i <= n - 1; i++)
      if (path[as[k]][bs[k]] == path[as[k]][i] + path[i][bs[k]]) {
        flag = true;
        break;
      }
    if (flag) ans++;
  }
  cout << ans << '\n';
}
int main(void) {
  solve();
  return 0;
}
