#include <bits/stdc++.h>
using namespace std;
int n, m, ans, e, w[110][110], path[110][110];
vector<int> G[110], W[110];
pair<int, int> E[1001];
int main() {
  memset(path, 0x3f, sizeof(path));
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    G[a].push_back(b);
    G[b].push_back(a);
    w[a][b] = w[b][a] = path[b][a] = path[a][b] = c;
    E[e++] = {a, b};
  }
  for (int i = 1; i <= n; i++) path[i][i] = 0;
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (path[i][j] > path[i][k] + path[k][j])
          path[i][j] = path[i][k] + path[k][j];
  for (int k = 0; k < e; k++) {
    bool flag = 0;
    int chk[110][110];
    memset(chk, 0x3f, sizeof(chk));
    for (int p = 1; !flag and p <= n; p++) {
      queue<int> q;
      q.push(p), chk[p][p] = 0;
      while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int i = 0; i < G[now].size(); i++) {
          int v = G[now][i];
          if (E[k].first == now and E[k].second == v) continue;
          if (E[k].first == v and E[k].second == now) continue;
          if (chk[p][v] > chk[p][now] + w[now][v])
            chk[p][v] = chk[p][now] + w[now][v], q.push(v);
        }
      }
      for (int i = 1; !flag and i <= n; i++)
        if (chk[p][i] != path[p][i]) flag = 1;
    }
    if (!flag) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
