#include <bits/stdc++.h>
using namespace std;
int INF = 2147483647;
long long LINF = 9223372036854775807;
long long MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  int edge[n][n];
  int dist[n][n];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      edge[i][j] = -1;
      dist[i][j] = 1000000;
    }
  int a[m], b[m], c[m];
  int s, t, u;
  for (int i = 0; i < m; ++i) {
    cin >> s >> t >> u;
    --s;
    --t;
    edge[s][t] = u;
    edge[t][s] = u;
    dist[s][t] = u;
    dist[t][u] = u;
    a[i] = s;
    b[i] = t;
    c[i] = u;
  }
  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]);
        dist[j][i] = dist[i][j];
      }
    }
  }
  int ans = m;
  for (int k = 0; k < m; ++k) {
    for (int i = 0; i < n; ++i) {
      int l = a[k];
      int r = b[k];
      if (dist[i][l] + edge[l][r] == dist[i][r]) {
        --ans;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
