#include <bits/stdc++.h>
using namespace std;
int a[10000][10000];
int b[10000][10000];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    a[x][y] = z;
    a[y][x] = z;
    b[x][y] = z;
    b[y][x] = z;
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        a[i][j] = min(a[i][k] + a[k][j], a[i][j]);
      }
    }
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] != 0 && b[i][j] != 0) {
        if (a[i][j] != b[i][j]) {
          sum++;
        }
      }
    }
  }
  cout << sum / 2 << endl;
  return 0;
}
