#include <bits/stdc++.h>
using namespace std;
const int INF = 10000;
int main() {
  int N, M;
  cin >> N >> M;
  int d[N + 2][N + 2];
  int V[N + 2][N + 2];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      V[i][j] = INF;
      d[i][j] = INF;
    }
  }
  int a, b, w;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> w;
    V[a][b] = w;
    V[b][a] = w;
  }
  for (int s = 1; s <= N; s++) {
    vector<bool> explored(N + 1, false);
    d[s][s] = 0;
    while (1) {
      int u = 0;
      int minv = INF;
      for (int i = 1; i <= N; i++) {
        if (explored[i] == false && d[s][i] < minv) {
          u = i;
          minv = d[s][i];
        }
      }
      if (u == 0) break;
      explored[u] = true;
      for (int i = 1; i <= N; i++) {
        if (d[s][u] + V[u][i] < d[s][i]) d[s][i] = d[s][u] + V[u][i];
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      bool shortest = false;
      for (int s = 1; s <= N; s++) {
        if (d[s][i] + V[i][j] == d[s][j]) shortest = true;
      }
      if (shortest) ans++;
    }
  }
  cout << M - ans << endl;
}
