#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int inf = 1e+7;
const long long INF = 1e+14;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
struct edge {
  long long to, cost;
};
long long d[110][110] = {INF};
long long N, M;
long long a[1010], b[1010], c[1010];
void warshall_floyd() {
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  vector<edge> G[1010];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    edge e1 = {b[i], c[i]}, e2 = {a[i], c[i]};
    G[a[i]].push_back(e1);
    G[b[i]].push_back(e2);
    d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
    d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
  }
  for (int i = 0; i < N; i++) d[i][i] = 0;
  warshall_floyd();
  int ans = M;
  for (int k = 0; k < M; k++) {
    bool pass = false;
    for (int i = 0; i < N; i++) {
      if (d[i][b[k]] == d[i][a[k]] + c[k]) {
        pass = true;
      }
    }
    if (pass == true) ans = ans - 1;
  }
  cout << ans << "\n";
  return 0;
}
