#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
void debugger(vector<vector<T> >& a, int n = -1, int m = -1) {
  if (n == -1 && m == -1) n = a.size(), m = a[0].size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cerr << setw(5) << (a[i][j] >= 9999 ? 9999 : a[i][j]);
    }
    cerr << endl;
  }
}
template <class T>
void debugger(vector<T>& a, int n = -1) {
  if (n == -1) n = a.size();
  for (int i = 0; i < n; i++) {
    cerr << setw(5) << (a[i] >= 9999 ? 9999 : a[i]);
  }
  cerr << endl;
}
int n, m;
int a[110], b[110], c[110];
int dist[110][110];
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        dist[i][j] = 0;
      else
        dist[i][j] = 1e8;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    chmin(dist[a[i]][b[i]], c[i]);
    chmin(dist[b[i]][a[i]], c[i]);
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        chmin(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    for (int s = 0; s < n; s++) {
      if (dist[s][b[i]] == (dist[s][a[i]] + c[i])) {
        ans--;
        break;
      }
    }
  }
  cout << ans << '\n';
}
