#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, a[1001], b[1001], c[1001];
  int dist[110][110];
  for (int i = (0); i < (110); i++)
    for (int j = (0); j < (110); j++) {
      dist[i][j] = 1e8;
      if (i == j) dist[i][j] = 0;
    }
  cin >> n >> m;
  for (int i = (0); i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    dist[a[i]][b[i]] = c[i];
    dist[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int res = m;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j <= n; j++) {
      if (dist[j][a[i]] + c[i] == dist[j][b[i]] ||
          dist[j][b[i]] + c[i] == dist[j][a[i]]) {
        res--;
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}
