#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 100000000 + 7;
const ll MAX_N = 1000;
int d[110][110];
int n, m, x, y, z, ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    x--;
    y--;
    d[x][y] = z;
    d[y][x] = z;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j)
        d[i][j] = 0;
      else
        d[i][j] = 1e9;
    }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (d[i][j] > 1) ans++;
    }
  }
  cout << ans / 2 << endl;
}
