#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
static const long long MOD = 1000000007;
static const long long LINF = (long long)(1e18 + 99);
static const int INF = 1e9 + 99;
int dist[105][105];
int A[105], B[105], C[105];
int ans;
int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < (105); i++)
    for (int j = (0); j < (105); j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = INF;
    }
  for (int i = (0); i < (m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = dist[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int k = 0; k < m; k++) {
    bool flag = false;
    int a = A[k], b = B[k], c = C[k];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dist[i][j] == dist[i][a] + dist[b][j] + c ||
            dist[i][j] == dist[i][b] + dist[a][j] + c)
          flag = true;
      }
    }
    if (!flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
