#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
static const string abet(
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI = 3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);
static const int dy4[] = {0, 0, 1, -1};
static const int dx4[] = {1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int dp[101][101];
  int a[101][101] = {{0, 0}};
  int N, M;
  cin >> N >> M;
  for (int i = (0); i < (101); ++i)
    for (int j = (0); j < (101); ++j) dp[i][j] = 10000000;
  for (int i = (0); i < (101); ++i) dp[i][i] = 0;
  for (int i = (0); i < (M); ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    dp[x][y] = dp[y][x] = z;
    a[x][y] = a[y][x] = z;
  }
  for (int i = (0); i < (101); ++i)
    for (int j = (0); j < (101); ++j)
      for (int k = (0); k < (101); ++k)
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
  int cnt = 0;
  for (int i = (0); i < (101); ++i)
    for (int j = (i + 1); j < (101); ++j)
      if (a[i][j] > dp[i][j]) cnt++;
  cout << cnt << endl;
  return 0;
}
