#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
constexpr int MAXN = 105;
constexpr int INF = 1000000000;
struct Node {
  int u, v, w;
};
int N;
int M;
Node var[MAXN * MAXN];
int dis[MAXN][MAXN];
int main() {
  scanf("%d%d\n", &N, &M);
  for (int i = 1; i <= M; ++i) {
    scanf("%d%d%d", &var[i].u, &var[i].v, &var[i].w);
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = i; j <= N; ++j) {
      dis[i][j] = dis[j][i] = INF;
    }
  }
  for (int i = 1; i <= M; ++i) {
    int u = var[i].u;
    int v = var[i].v;
    int w = var[i].w;
    dis[u][v] = dis[v][u] = w;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      if (i != j) {
        for (int k = 1; k <= N; ++k) {
          if (k != i && k != j) {
            if (dis[i][k] + dis[k][j] < dis[i][j]) {
              dis[i][j] = dis[i][k] + dis[k][j];
            }
          }
        }
      }
    }
  }
  int tempAns = 0;
  for (int i = 1; i <= M; ++i) {
    int u = var[i].u;
    int v = var[i].v;
    int w = var[i].w;
    if (dis[u][v] < w) {
      ++tempAns;
    }
  }
  printf("%d\n", tempAns);
  return 0;
}
