#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
int N, M;
int G[101][101];
int dist[101][101];
int a[1001], b[1001], c[1001];
int ans;
void d_init() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = INF;
    }
  }
  for (int i = 0; i < N; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (G[i][j]) dist[i][j] = G[i][j];
    }
  }
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    G[a[i]][b[i]] = c[i];
    G[b[i]][a[i]] = c[i];
  }
  d_init();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cout << dist[i][j] << endl;
    }
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (j == k) continue;
        if (dist[j][a[i]] + c[i] + dist[b[i]][k] == dist[j][k]) {
          ans++;
        }
      }
    }
  }
  cout << M - ans / 2 << endl;
}
