#include <bits/stdc++.h>
using namespace std;
int n, m;
int e[105][105];
int d[105][105];
int use[105][105];
int a[105][105];
void warshall_floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          a[i][j] = k;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] != -1) {
        int k = a[i][j];
        use[i][k]++;
        use[k][j]++;
      } else
        use[i][j]++;
    }
  }
}
int main() {
  cin >> n >> m;
  int ai, b, c;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a[i][j] = -1;
      d[i][j] = 999999;
      if (i == j) d[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> ai >> b >> c;
    ai--;
    b--;
    e[ai][b]++;
    e[b][ai]++;
    d[ai][b] = c;
    d[b][ai] = c;
  }
  warshall_floyd();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (e[i][j] != 0 && use[i][j] == 0) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
