#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int x;
  cin >> x;
  return x;
}
long long int nxtl() {
  long long int x;
  cin >> x;
  return x;
}
void SieveOfEratosthenes(int n, vector<int> &primes) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int power(long long int x, long long int y, long long int mod) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2, mod);
  if (y % 2 == 0)
    return (temp * temp) % mod;
  else
    return (((x * temp) % mod) * temp) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = nxt(), m = nxt();
  vector<vector<int> > edges;
  vector<int> row(3);
  edges.resize(m, row);
  vector<vector<int> > dist;
  vector<int> r2;
  r2.resize(n + 1, 1e9);
  dist.resize(n + 1, r2);
  for (int i = 1; i <= n; i++) dist[i][i] = 0;
  for (int i = 0; i < m; i++) {
    int u = nxt(), v = nxt(), c = nxt();
    edges[i][0] = u;
    edges[i][1] = v;
    edges[i][2] = c;
    dist[u][v] = c;
    dist[v][u] = c;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++)
        if (dist[i][j] > dist[i][k] + dist[k][j])
          dist[i][j] = dist[i][k] + dist[k][j];
  int test = 0;
  for (int i = 0; i < m; i++) {
    if (edges[i][2] > dist[edges[i][0]][edges[i][1]]) test++;
  }
  cout << test << endl;
  return 0;
}
