#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y, len;
  cin >> n >> m;
  int disy[105][105], disx[105][105];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        disy[i][j] = 0, disx[i][j] = 0;
      else
        disy[i][j] = 0x7fffffff, disx[i][j] = 0x7fffffff;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> len;
    x -= 1, y -= 1;
    disy[x][y] = len, disy[y][x] = len;
    disx[x][y] = len, disx[y][x] = len;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        disx[i][j] = min(disx[i][j], disx[i][k] + disx[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (disx[i][j] != disy[i][j]) ans++;
    }
  }
  cout << ans / 2;
  return 0;
}
