#include <bits/stdc++.h>
using namespace std;
int INF = 1 << 29;
int main() {
  int N, M, Ans = 0;
  cin >> N >> M;
  int table[N + 1][N + 1];
  int copy[N + 1][N + 1];
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < N + 1; j++) {
      table[i][j] = 0;
      copy[i][j] = 0;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    table[a][b] = c;
    table[b][a] = c;
    copy[a][b] = c;
    copy[b][a] = c;
  }
  for (int k = 1; k < N + 1; k++) {
    for (int i = 1; i < N + 1; i++) {
      for (int j = 1; j < N + 1; j++) {
        table[i][j] = min(table[i][k] + table[k][j], table[i][j]);
      }
    }
  }
  for (int i = 1; i < N + 1; i++) {
    for (int j = 1; j < N + 1; j++) {
      if (copy[i][j] == 0) continue;
      if (copy[i][j] > table[i][j]) Ans++;
    }
  }
  assert(Ans % 2 == 0);
  cout << Ans / 2 << endl;
  return 0;
}
