#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > st;
long long n, a, b, c, m, d[200][200];
long long pre[200][200];
void path(int s, int g) {
  long long c;
  long long ta, tb;
  vector<long long> tmp;
  for (c = s; c != g; c = pre[c][g]) {
    tmp.push_back(c);
  }
  for (int i = 1; i < tmp.size(); i++) {
    ta = tmp[i - 1];
    tb = tmp[i];
    if (ta > tb) {
      swap(ta, tb);
    }
    st.insert(pair<long long, long long>(ta, tb));
  }
}
signed main() {
  fill(d[0], d[200], 1000000000);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    a--;
    b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      pre[i][j] = j;
    }
    d[i][i] = 0;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        long long tmp = d[i][k] + d[k][j];
        if (tmp < d[i][j]) {
          d[i][j] = tmp;
          pre[i][j] = pre[i][k];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      path(i, j);
    }
  }
  cout << m - st.size() - 1 << endl;
}
