#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int g[110][110] = {};
int N, M;
int d[110][110];
int used[110][110] = {};
void init() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = INF;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (g[i][j] != 0) d[i][j] = g[i][j];
    }
  }
}
void warshall_floyd() {
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a][b] = c;
    g[b][a] = c;
  }
  init();
  warshall_floyd();
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (i == k || j == k || i == j) continue;
        if (g[k][j] == 0) continue;
        if (d[i][k] + g[k][j] == d[i][j]) {
          if (used[k][j] == true) continue;
          used[k][j] = true;
          ans++;
        }
      }
    }
  }
  cout << M - ans << endl;
}
