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