#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qp(long long a, long long b) {
  long long ans = 1;
  do {
    if (b & 1) ans = 1ll * ans * a;
    a = 1ll * a * a;
  } while (b >>= 1);
  return ans;
}
long long qp(long long a, long long b, long long mo) {
  long long ans = 1;
  do {
    if (b & 1) ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
int n, m;
int a[110], b[110];
int cost[110][110], edge[110];
void print_all_cost() {
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) cout << cost[i][j] << " ";
    cout << '\n';
  }
  cout << '\n';
}
void Warshall_Floyd() {
  for (int corner = 0; corner < n; corner++) {
    for (int s = 0; s < n; s++) {
      for (int t = 0; t < n; t++) {
        if (cost[s][t] > cost[s][corner] + cost[corner][t]) {
          cost[s][t] = cost[s][corner] + cost[corner][t];
        }
      }
    }
  }
}
bool check_include_shortestpath(int x) {
  int s = a[x], t = b[x];
  for (int i = 0; i < n; i++) {
    if (cost[i][t] == cost[i][s] + edge[x]) return true;
  }
  return false;
}
int main(void) {
  cin >> n >> m;
  for (long long i = 0; i < 110; i++)
    for (long long j = 0; j < 110; j++) {
      if (i == j)
        cost[i][j] = 0;
      else
        cost[i][j] = INT_MAX / 3;
    }
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    cin >> edge[i];
    cost[a[i]][b[i]] = min(cost[a[i]][b[i]], edge[i]);
    cost[b[i]][a[i]] = min(cost[b[i]][a[i]], edge[i]);
  }
  Warshall_Floyd();
  int count = m;
  for (long long i = 0; i < m; i++) {
    if (check_include_shortestpath(i)) {
      count--;
    }
  }
  cout << count << '\n';
}
