#include <bits/stdc++.h>
using namespace std;
void gen_sosuu(int sosuu[]) {
  for (int i = 0; i < (int)(100010); i++) {
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  for (int i = (2); i < (int)(sqrt(100000) + 1); i++) {
    if (sosuu[i] == false) continue;
    for (int j = 2; i * j <= 100000; j++) {
      sosuu[i * j] = false;
    }
  }
}
int n, m;
int graph[101][101];
bool visit[101][101] = {{false}};
int d[101];
bool used[101];
int from[101];
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(m); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    graph[a][b] = c;
    graph[b][a] = c;
  }
  for (int i = (1); i < (int)(n + 1); i++) {
    for (int j = 0; j < (int)(n + 1); j++) {
      d[j] = 1 << 29;
      used[j] = false;
    }
    d[i] = 0;
    for (int l = 0; l < (int)(n); l++) {
      int id = 1;
      for (int j = (1); j < (int)(n + 1); j++) {
        if (!used[j] && d[id] > d[j]) id = j;
      }
      used[id] = true;
      for (int j = (1); j < (int)(n + 1); j++) {
        if (graph[id][j] == 0) continue;
        if (d[j] > d[id] + graph[id][j]) {
          d[j] = d[id] + graph[id][j];
          from[j] = id;
        }
      }
    }
    for (int j = (1); j < (int)(n + 1); j++) {
      if (i == j) continue;
      visit[j][from[j]] = true;
      visit[from[j]][j] = true;
    }
  }
  int sum = 0;
  for (int i = (1); i < (int)(n + 1); i++)
    for (int j = (1); j < (int)(n + 1); j++) {
      if (visit[i][j]) sum++;
    }
  sum /= 2;
  cout << m - sum << endl;
}
