#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
const double eps = 1e-8;
int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int N, M;
long long dist[100][100];
long long cost[100][100];
void warshall_floyd() {
  for (int k = 0; k < N; k++)
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      dist[i][j] = cost[i][j] = (1L << 29);
      dist[j][i] = cost[j][i] = (1L << 29);
    }
  }
  cin >> N >> M;
  int a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    dist[a - 1][b - 1] = cost[a - 1][b - 1] = c;
    dist[b - 1][a - 1] = cost[b - 1][a - 1] = c;
  }
  warshall_floyd();
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      cnt += (cost[i][j] > dist[i][j]);
    }
  }
  cout << cnt / 2 << endl;
  return 0;
}
