#include <bits/stdc++.h>
using std::cin;
using std::cout;
using namespace std;
long long gcd(long long a, long long b) {
  while (b != 0) {
    auto tmp = a;
    a = b;
    b = tmp % a;
  }
  return a;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void oneCase() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d(n, vector<int>(n, 0));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    d[a][b] += c;
    d[b][a] += c;
  }
  auto res = d;
  auto e = d;
  for (int m = 0; m < n; ++m) {
    for (int l = 0; l < n; ++l) {
      for (int r = 0; r < n; ++r) {
        if (d[l][r] == 0) {
          continue;
        }
        if (d[l][r] > d[l][m] + d[m][r]) {
          if (e[l][r] > 0) {
            res[l][r] = -1;
          }
          d[l][r] = d[l][m] + d[m][r];
        }
      }
    }
  }
  int count = 0;
  for (auto& row : res) {
    for (auto v : row) {
      if (v == -1) {
        ++count;
      }
    }
  }
  cout << count / 2 << "\n";
}
int main() {
  int t = 1;
  while (t > 0) {
    oneCase();
    --t;
  }
  return 0;
}
