#include <bits/stdc++.h>
using namespace std;
long long dis[114][114];
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a, b, c;
  for (long long i = 0; i < m; i++) {
    long long tx, ty, tc;
    cin >> tx >> ty >> tc;
    a.push_back(tx - 1);
    b.push_back(ty - 1);
    c.push_back(tc);
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      dis[i][j] = 1000000007;
      if (i == j) dis[i][j] = 0;
    }
  }
  for (long long i = 0; i < n; i++) {
    dis[a[i]][b[i]] = c[i];
    dis[b[i]][a[i]] = c[i];
  }
  for (long long k = 0; k < n; k++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < n; j++) {
        if (dis[i][j] > dis[i][k] + dis[k][j])
          dis[i][j] = dis[i][k] + dis[k][j];
      }
    }
  }
  long long cnt = 0;
  for (long long i = 0; i < m; i++) {
    long long fl = 0;
    for (long long j = 0; j < n; j++) {
      for (long long k = 0; k < n; k++) {
        if (dis[j][k] == dis[j][a[i]] + dis[b[i]][k] + c[i]) fl = 1;
      }
    }
    if (fl == 0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
