#include <bits/stdc++.h>
using namespace std;
long long INFL = 1000000000000000010;
int INF = 2147483600;
long long MOD = 1000000007;
void solve() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> edge(110, vector<int>(110, -1));
  vector<vector<int>> d(110, vector<int>(110, INF));
  for (int i = 0; i < N; i++) {
    d[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edge[a][b] = c;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (edge[i][j] == -1) continue;
      if (edge[i][j] != d[i][j]) res++;
    }
  }
  cout << res << endl;
}
int main(void) { solve(); }
