#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
int INF = 1000000007;
using ll = long long;
int main() {
  int n, m;
  int a[110], b[110], c[110];
  bool f[100][100] = {};
  cin >> n >> m;
  int dp[100][100] = {};
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      dp[i][j] = dp[j][i] = INF;
    }
  }
  for (int i = 1; i < m + 1; i++) {
    cin >> a[i] >> b[i] >> c[i];
    dp[a[i]][b[i]] = dp[b[i]][a[i]] = c[i];
  }
  for (int k = 1; k < n + 1; k++) {
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < n + 1; j++) {
        if (i == j || i == k || j == k) break;
        if (dp[i][j] >= dp[i][k] + dp[k][j]) {
          dp[i][j] = dp[i][k] + dp[k][j];
          f[i][k] = f[k][j] = 1;
        }
        if (dp[i][j] <= dp[i][k] + dp[k][j]) {
          f[i][j] = f[j][i] = 1;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      ans += f[i][j];
    }
  }
  cout << m - ans / 2 << endl;
}
