#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mo = 1000000007;
inline void gn(long long &x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
inline void gn(long double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
template <class T1, class T2>
inline void gn(T1 &r, T2 &s) {
  gn(r), gn(s);
}
template <class T1, class T2, class T3>
inline void gn(T1 &r, T2 &s, T3 &t) {
  gn(r), gn(s), gn(t);
}
template <class T1, class T2, class T3, class T4>
inline void gn(T1 &r, T2 &s, T3 &t, T4 &u) {
  gn(r), gn(s), gn(t), gn(u);
}
inline void gs(char *s) { scanf("%s", s); }
inline void gc(char &c) {
  while ((c = getchar()) > 126 || c < 33)
    ;
}
inline void pc(char c) { putchar(c); }
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mo;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
long long powmod(long long a, long long b, long long mo) {
  long long res = 1;
  a %= mo;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 111, M = 111111;
int l, m, n, t, C, x, y, z;
int a[N][N], b[N][N];
struct zcc {
  int x, y, z;
} E[M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); ++i)
    scanf("%d%d%d", &x, &y, &z), a[x][y] = b[x][y] = b[y][x] = z,
                                 E[i] = {x, y, z};
  for (int k = (1); k <= (n); ++k)
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (n); ++j)
        b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
  int ans = 0;
  for (int j = (1); j <= (m); ++j) {
    int ok = 0;
    int x = E[j].x, y = E[j].y;
    if (b[x][y] == E[j].z) ok = 1;
    if (!ok) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
