#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 path(long long s, long long g, long long n, long long* p) {
  int ans = 1;
  p[0] = s;
  while (s != g) {
    for (long long i = (0); i < (n); i++)
      if (i != s && cost[s][i] && cost[s][i] + dddd[i][g] == dddd[s][g]) {
        p[ans++] = i;
        s = i;
        break;
      }
  }
  return ans;
}
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);
  long long p[110], b[110][110] = {};
  for (long long i = (0); i < (n); i++)
    for (long long j = (0); j < (n); j++) {
      int cnt = path(i, j, n, p);
      for (long long k = (0); k < (cnt - 1); k++)
        b[p[k]][p[k + 1]] = b[p[k + 1]][p[k]] = 1;
    }
  int ans = 0;
  for (long long i = (0); i < (n); i++)
    for (long long j = (0); j < (n); j++) ans += b[i][j];
  printf("%d\n", m - ans / 2);
  return 0;
}
