#include <bits/stdc++.h>
using namespace std;
inline int read() {
  long long s = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
  return s * f;
}
inline void out(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 1005;
struct Edge {
  int u, v;
  int val;
};
struct node {
  int a, b, c;
} s[maxn];
vector<Edge> edge[maxn];
int look[maxn][maxn];
int n, m;
int dis[maxn];
bool vis[maxn];
void init() {
  memset(look, -1, sizeof(look));
  memset(s, 0, sizeof(s));
  for (int i = 0; i <= n; i++) {
    edge[i].clear();
  }
}
void spfa(long long s) {
  queue<long long> q;
  memset(dis, 88, sizeof(dis));
  memset(vis, false, sizeof(vis));
  q.push(s);
  dis[s] = 0;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    vis[u] = false;
    for (long long i = 0; i < edge[u].size(); i++) {
      if (dis[edge[u][i].v] > dis[u] + edge[u][i].val) {
        dis[edge[u][i].v] = dis[u] + edge[u][i].val;
        look[u][edge[u][i].v] = 1;
        if (!vis[edge[u][i].v]) {
          vis[edge[u][i].v] = true;
          q.push(edge[u][i].v);
        }
      }
    }
  }
}
int main() {
  while (~scanf("%d %d", &n, &m)) {
    init();
    for (int i = 0; i < m; i++) {
      s[i].a = read();
      s[i].b = read();
      s[i].c = read();
      Edge E, K;
      E.u = s[i].a;
      E.v = s[i].b;
      E.val = s[i].c;
      K.u = s[i].b;
      K.v = s[i].a;
      K.val = s[i].c;
      look[s[i].a][s[i].b] = 0;
      edge[s[i].a].push_back(E);
      edge[s[i].b].push_back(K);
    }
    spfa(1);
    int ans = 0;
    for (int i = 0; i <= m; i++) {
      for (int j = 0; j < edge[i].size(); j++) {
        if (look[i][edge[i][j].v] == 0) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
