#include <bits/stdc++.h>
using namespace std;
int n, m;
int dp[100][100];
int a[1000], b[1000], c[1000];
void initialize(void) {
  for (int lp1 = 0; lp1 < 100; lp1++) {
    for (int lp2 = 0; lp2 < 100; lp2++) {
      if (lp1 == lp2) {
        dp[lp1][lp2] = 0;
      } else {
        dp[lp1][lp2] = 1000000;
        ;
      }
    }
  }
}
void input(void) {
  int edge_a, edge_b, edge_c;
  scanf("%d %d", &n, &m);
  for (int lp1 = 0; lp1 < m; lp1++) {
    scanf("%d %d %d", &edge_a, &edge_b, &edge_c);
    a[lp1] = edge_a;
    b[lp1] = edge_b;
    c[lp1] = edge_c;
    dp[edge_a - 1][edge_b - 1] = edge_c;
    dp[edge_b - 1][edge_a - 1] = edge_c;
  }
}
void shortestpath(void) {
  for (int lp1 = 0; lp1 < n; lp1++) {
    for (int lp2 = 0; lp2 < n; lp2++) {
      for (int lp3 = 0; lp3 < n; lp3++) {
        if (dp[lp1][lp2] > dp[lp1][lp3] + dp[lp3][lp2]) {
          dp[lp1][lp2] = dp[lp1][lp3] + dp[lp3][lp2];
        }
      }
    }
  }
}
void pathprint(void) {
  printf("pathprint called\n");
  for (int lp1 = 0; lp1 < n; lp1++) {
    for (int lp2 = 0; lp2 < n; lp2++) {
      printf("%d to %d is %d\n", lp1, lp2, dp[lp1][lp2]);
    }
  }
}
int solve(void) {
  bool shortest = false;
  int answer = m;
  for (int lp1 = 0; lp1 < m; lp1++) {
    shortest = false;
    for (int lp2 = 0; lp2 < n; lp2++) {
      if (dp[lp2][a[lp1]] + c[lp1] == dp[lp2][b[lp1]]) {
        shortest = true;
      }
    }
    if (shortest == true) {
      answer--;
    }
  }
  return answer;
}
int main(void) {
  initialize();
  input();
  shortestpath();
  printf("%d\n", solve());
  return 0;
}
