#include <bits/stdc++.h>
using namespace std;
const int M = 100010;
int INF = 1000000007;
using ll = long long;
int main() {
  int n, m;
  int a[110], b[110], c[110];
  cin >> n >> m;
  int dis[110][110] = {};
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      dis[i][j] = dis[j][i] = INF;
    }
  }
  for (int i = 1; i < m + 1; i++) {
    cin >> a[i] >> b[i] >> c[i];
    dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
  }
  for (int k = 1; k < n + 1; k++) {
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < n + 1; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  int ans = m;
  for (int i = 1; i < m + 1; i++) {
    bool f = false;
    for (int j = 1; j < n + 1; j++)
      if (dis[j][a[i]] + c[i] == dis[j][b[i]]) f = true;
    if (f) ans--;
  }
  cout << ans << endl;
}
