#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int cost[100][100], next[100][100];
  bool unused[100][100];
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cost[i][j] = 1e+9;
      next[i][j] = j;
    }
  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;
    unused[a - 1][b - 1] = true;
    unused[b - 1][a - 1] = true;
  }
  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] + cost[k][j]) {
          cost[i][j] = cost[i][k] + cost[k][j];
          next[i][j] = next[i][k];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int prev = i;
      for (int k = i; k != j; k = next[k][j]) {
        unused[prev][k] = false;
        unused[k][prev] = false;
        prev = k;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (unused[i][j]) res++;
    }
  }
  cout << res / 2 << endl;
  return 0;
}
