#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main() {
  int N, M;
  cin >> N >> M;
  bool ans[N + 1][N + 1];
  int V[N + 2][N + 2];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      V[i][j] = INF;
      ans[i][j] = false;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    V[a][b] = w;
    V[b][a] = w;
  }
  for (int s = 1; s <= N; s++) {
    int d[N + 2];
    for (int i = 1; i <= N; i++) d[i] = INF;
    vector<bool> explored(N + 1, false);
    d[s] = 0;
    while (1) {
      int u = -1;
      int minv = INF;
      for (int i = 1; i <= N; i++) {
        if (explored[i] == false && d[i] < minv) {
          u = i;
          minv = d[i];
        }
      }
      if (u == -1) break;
      int v = -1;
      for (int i = 1; i <= N; i++) {
        if (d[i] + V[i][u] == d[u]) v = i;
      }
      if (v != -1) {
        ans[v][u] = true;
        ans[u][v] = true;
      }
      explored[u] = true;
      for (int i = 1; i <= N; i++) {
        if (d[u] + V[u][i] < d[i]) d[i] = d[u] + V[u][i];
      }
    }
  }
  int count = 0;
  for (int a = 1; a <= N; a++) {
    for (int j = 1; j <= N; j++) {
      if (!ans[a][j] && V[a][j] != INF) count++;
    }
  }
  cout << count / 2 << endl;
}
