#include <bits/stdc++.h>
const long long int MOD = 1000000007;
using namespace std;
struct Edge {
  int from;
  int to;
  int cost;
  int index;
  Edge(int to, int from, int cost, int index)
      : from(from), to(to), cost(cost), index(index) {}
  Edge() {}
};
long long int Map[105][105];
int INF = (1 << 30) + 1;
int N, M;
bool U[1005];
Edge e[1005];
int P[105][105];
void path(int s, int g) {
  if (s == g) {
    return;
  }
  int stack[105];
  int p = P[s][g];
  int c = p;
  while (c != s) {
    c = P[s][p];
    for (long long int i = (long long int)(0); i < (long long int)(M); ++i) {
      if ((c == e[i].to && p == e[i].from) ||
          (c == e[i].from && p == e[i].to)) {
        U[i] = true;
        break;
      }
    }
    p = c;
  }
}
int main() {
  cin >> N >> M;
  for (long long int i = (long long int)(0); i < (long long int)(N); ++i) {
    for (long long int j = (long long int)(0); j < (long long int)(N); ++j) {
      Map[i][j] = INF;
      P[i][j] = i;
    }
    Map[i][i] = 0;
  }
  for (long long int i = (long long int)(0); i < (long long int)(M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    Map[a][b] = Map[b][a] = c;
    e[i] = Edge(a, b, c, i);
  }
  for (long long int k = (long long int)(0); k < (long long int)(N); ++k) {
    for (long long int i = (long long int)(0); i < (long long int)(N); ++i) {
      for (long long int j = (long long int)(0); j < (long long int)(N); ++j) {
        if (Map[i][j] > Map[i][k] + Map[k][j]) {
          Map[i][j] = Map[i][k] + Map[k][j];
          P[i][j] = P[k][j];
        }
      }
    }
  }
  for (long long int i = (long long int)(0); i < (long long int)(N); ++i) {
    for (long long int j = (long long int)(0); j < (long long int)(N); ++j) {
      path(i, j);
    }
  }
  int ans = 0;
  for (long long int i = (long long int)(0); i < (long long int)(M); ++i) {
    if (U[i] == false) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
