#include <bits/stdc++.h>
using namespace std;
int n, m, s, d[105][105], t1[1005], t2[1005], t3[1005], v[105][105];
int main() {
  int i, j, k;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      d[i][j] = 2e9;
    }
    d[i][i] = 0;
  }
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &t1[i], &t2[i], &t3[i]);
    d[t1[i]][t2[i]] = d[t2[i]][t1[i]] = t3[i];
    v[t1[i]][t2[i]] = v[t2[i]][t1[i]] = 1;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        if (d[i][k] + d[k][j] < d[i][j] && i != k && k != j) {
          d[i][j] = d[i][k] + d[k][j];
          v[i][j] = v[j][i] = 0;
        }
      }
    }
  }
  for (i = 0; i < m; i++) s += 1 - v[t1[i]][t2[i]];
  cout << s;
  return 0;
}
