#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const int N_MAX = 101;
int C[N_MAX][N_MAX] = {};
int C_original[N_MAX][N_MAX] = {};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  for (int i = (0); i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    C[a][b] = c;
    C[b][a] = c;
    C_original[a][b] = c;
    C_original[b][a] = c;
  }
  for (int i = (1); i < (N + 1); ++i) {
    for (int j = (1); j < (N + 1); ++j) {
      for (int k = (1); k < (N + 1); ++k) {
        C[j][k] = min(C[j][k], C[j][i] + C[i][k]);
      }
    }
  }
  long long count = 0;
  for (int i = (1); i < (N + 1); ++i) {
    for (int j = (1); j < (N + 1); ++j) {
      if (C[i][j] != C_original[i][j]) {
        count++;
      }
    }
  }
  cout << (count / 2) << endl;
  return 0;
}
