#include <bits/stdc++.h>
using namespace std;
int map[105][105];
int maze[105][105];
int mm[105][105];
int f[105][105];
int n, m;
int t1, t2, t3;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) {
        map[i][j] = 0;
        maze[i][j] = -1;
      } else {
        map[i][j] = 0x3f3f3f3f;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> t1 >> t2 >> t3;
    map[t1][t2] = t3;
    map[t2][t1] = t3;
    mm[t1][t2] = t3;
    mm[t2][t1] = t3;
    maze[t1][t2] = t3;
    maze[t2][t1] = t3;
    f[t1][t2] = 1;
    f[t2][t1] = 1;
  }
  int x, y;
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        x = map[i][j];
        if (map[i][j] > map[i][k] + map[k][j]) {
          map[i][j] = map[i][k] + map[k][j];
        }
        if (x == map[i][j]) {
          maze[i][j] = x;
          maze[j][i] = x;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (maze[i][j] != mm[i][j] && f[i][j] == 1) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
