#include <bits/stdc++.h>
using namespace std;
const int inf = 99999999;
const long long linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
long long modpow(long long i, long long j) {
  long long tmp = 1;
  while (j) {
    if (j % 2) tmp = ((tmp * i) % (long long)(1e9 + 7));
    i = ((i * i) % (long long)(1e9 + 7));
    j /= 2;
  }
  return tmp;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int n, m;
  long long d[200][200] = {};
  cin >> n >> m;
  for (int i = (0); i < (int)(n); i++)
    for (int j = (0); j < (int)(n); j++)
      if (i != j) d[i][j] = linf;
  for (int i = (0); i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  for (int k = (0); k < (int)(n); k++) {
    for (int i = (0); i < (int)(n); i++) {
      for (int j = (0); j < (int)(n); j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  cout << (m - (n - 1)) << endl;
  return 0;
}
