#include <bits/stdc++.h>
using namespace std;
int vis[105][105];
int mp[105][105];
int main() {
  int n, m, x, y, l;
  int i, j, k;
  while (~scanf("%d%d", &n, &m)) {
    for (j = 1; j <= n; j++) {
      for (i = 1; i <= n; i++) {
        mp[j][i] = 9999999;
      }
    }
    memset(vis, 0, sizeof(vis));
    for (i = 0; i < m; i++) {
      scanf("%d%d%d", &x, &y, &l);
      mp[x][y] = l;
      mp[y][x] = l;
      vis[x][y] = 1;
      vis[y][x] = 1;
    }
    for (j = 1; j <= n; j++) {
      for (i = 1; i <= n; i++) {
        if (j != i) {
          for (k = 1; k <= n; k++) {
            if (mp[j][k] + mp[k][i] < mp[j][i]) {
              mp[j][i] = mp[j][k] + mp[k][i];
              if (vis[j][k] == 1) {
                vis[j][k] = 2;
                vis[k][j] = 2;
              }
            }
          }
        }
      }
    }
    int ans = 0;
    for (j = 1; j <= n; j++) {
      for (i = 1; i <= n; i++) {
        if (vis[j][i] == 1) {
          ans++;
          break;
        }
      }
    }
    printf("%d\n", ans / 2);
  }
  return 0;
}
