#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int cost[100][100], cost2[100][100];
  bool used[100][100] = {};
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cost[i][j] = 1e+9;
  for (int i = 0; i < n; i++) cost[i][i] = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    cost[a - 1][b - 1] = c;
    cost[b - 1][a - 1] = c;
    used[a - 1][b - 1] = true;
    used[b - 1][a - 1] = true;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cost2[i][j] = cost[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (cost[i][j] - cost[i][k] == cost2[k][j]) {
          used[j][k] = false;
          used[k][j] = false;
        }
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (used[i][j]) res++;
    }
  }
  cout << res << endl;
  return 0;
}
