#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 110;
const long long int INF = 1e15;
long long int d[MAX_N][MAX_N];
long long int cost[MAX_N][MAX_N];
int main() {
  long long int N, M;
  cin >> N >> M;
  for (long long int i = 0; i < N; i++) {
    for (long long int j = 0; j < N; j++) {
      cost[i][j] = d[i][j] = INF;
      if (i == j) d[i][j] = 0;
    }
  }
  for (long long int i = 0; i < M; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    cost[a][b] = d[a][b] = c;
    cost[b][a] = d[b][a] = c;
  }
  for (long long int i = 0; i < N; i++) {
    for (long long int j = 0; j < N; j++) {
      for (long long int k = 0; k < N; k++) {
        if (d[i][k] + d[k][j] < d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < N; i++) {
    for (long long int j = 0; j < N; j++) {
      if (cost[i][j] > d[i][j] && cost[i][j] != INF) ans++;
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
