#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void init();
void solve();
signed main() {
  init();
  solve();
}
int cost[100][100];
int minc[100][100];
int N, M;
void init() {
  for (int i = 0; i < (int)(100); i++)
    for (int j = 0; j < (int)(100); j++) cost[i][j] = 10000000;
  for (int i = 0; i < (int)(100); i++) cost[i][i] = 0;
  cin >> N >> M;
  for (int i = 0; i < (int)(M); i++) {
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    a--;
    b--;
    cost[a][b] = cost[b][a] = c;
    minc[a][b] = minc[b][a] = c;
  }
}
void solve() {
  int res = 0;
  for (int k = 0; k < (int)(N); k++)
    for (int i = 0; i < (int)(N); i++)
      for (int j = 0; j < (int)(N); j++) {
        minc[i][j] = min(minc[i][j], minc[i][k] + minc[k][j]);
      }
  for (int i = 0; i < (int)(N); i++) {
    for (int j = (int)(i); j < (int)(N); j++) {
      if (cost[i][j] != 10000000 && cost[i][j] != minc[i][j]) res++;
    }
  }
  cout << res << endl;
}
