#include <bits/stdc++.h>
using namespace std;
int e[110][110];
int d[110][110];
int n;
void warshall_floyd() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (d[i][j] != 10000000) continue;
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 10000000;
    }
  }
  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];
        }
      }
    }
  }
}
bool contains(int i, int j) {
  for (int s = 0; s < n; s++) {
    if (s == j) continue;
    if (d[s][i] + e[i][j] == d[s][j]) return true;
  }
  return false;
}
int main() {
  int m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      e[i][j] = 0;
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    e[a - 1][b - 1] = c;
    e[b - 1][a - 1] = c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  warshall_floyd();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (e[i][j] != 10000000 && e[i][j] > d[i][j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
