#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int m, n;
  cin >> n >> m;
  int a[n][n], d[n][n];
  memset(a, 0x3f, sizeof(a));
  memset(d, 0x3f, sizeof(d));
  set<array<int, 3> > s;
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
    a[i][i] = 0;
  }
  for (int i = 0, j, k, c; i < m; i++) {
    cin >> j >> k >> c, --j, --k;
    a[j][k] = c;
    a[k][j] = c;
    s.insert({j, k, c});
  }
  int ans = 0;
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
  for (auto it : s) {
    int flag = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (a[i][it[0]] + a[it[1]][j] == a[i][j]) {
          flag = 1;
          break;
        }
      }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
