#include <bits/stdc++.h>
long long cost[110][110];
long long dddd[110][110];
void waasharuhuroido(long long n) {
  for (long long i = (0); i < (n); i++)
    for (long long j = (0); j < (n); j++)
      dddd[i][j] = i == j       ? 0
                   : cost[i][j] ? cost[i][j]
                                : ((1LL << 62) - (1LL << 31));
  for (long long k = (0); k < (n); k++)
    for (long long i = (0); i < (n); i++)
      for (long long j = (0); j < (n); j++)
        dddd[i][j] = ((dddd[i][j]) < (dddd[i][k] + dddd[k][j])
                          ? (dddd[i][j])
                          : (dddd[i][k] + dddd[k][j]));
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (long long i = (0); i < (m); i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--;
    b--;
    cost[a][b] = cost[b][a] = c;
  }
  waasharuhuroido(n);
  int ans = 0;
  for (long long i = (0); i < (n); i++)
    for (long long j = (i + 1); j < (n); j++)
      if (cost[i][j]) {
        int f = 1;
        for (long long ii = (0); ii < (n); ii++)
          for (long long jj = (0); jj < (n); jj++)
            if (dddd[ii][i] + cost[i][j] + dddd[j][jj] == dddd[ii][ii]) f = 0;
        ans += f;
      }
  printf("%d\n", m - ans);
  return 0;
}
