#include <bits/stdc++.h>
using namespace std;
int color[100], d[100], n, M[100][100];
vector<pair<int, int> > vec[100];
priority_queue<pair<int, int> > PQ;
int ShortestPath[100][100];
void prim(int s) {
  for (int i = 0; i < n; i++) {
    color[i] = 0;
    d[i] = 1000000007;
  }
  vector<int> p[n];
  d[s] = 0;
  p[s].push_back(-1);
  int mincost, u;
  while (true) {
    mincost = 1000000007;
    for (int i = 0; i < n; i++) {
      if (color[i] != 2 && d[i] < mincost) {
        mincost = d[i];
        u = i;
      }
    }
    if (mincost == 1000000007) break;
    color[u] = 2;
    for (int v = 0; v < n; v++) {
      if (color[v] != 2 && M[u][v] != 0) {
        if (M[u][v] == d[v]) {
          p[v].push_back(u);
          color[v] = 1;
        }
        if (M[u][v] < d[v]) {
          d[v] = M[u][v];
          while (!p[v].empty()) p[v].pop_back();
          p[v].push_back(u);
          color[v] = 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == s) continue;
    for (int j = 0; j < p[i].size(); j++) {
      ShortestPath[p[i][j]][i] = 0;
    }
  }
}
int main() {
  int m, a, b, c, count = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b >> c;
    M[a - 1][b - 1] = c;
    M[b - 1][a - 1] = c;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (M[i][j] == 0) {
        ShortestPath[i][j] = 2;
      } else {
        ShortestPath[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) prim(i);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (ShortestPath[i][j] == 1) count++;
  }
  cout << count / 2 << endl;
  return 0;
}
