#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
const int MAX = 1100;
const int INFTY = 1 << 21;
const int WHITE = 1;
const int BLACK = 2;
const int GRAY = 3;
bool used[MAX][MAX];
int N, M;
pair<int, bool> list[MAX][MAX];
void dijkstra(int s) {
  vector<int> d(N, INFTY);
  vector<int> color(N, WHITE);
  vector<int> par(N, -1);
  d[s] = 0;
  color[s] = GRAY;
  while (true) {
    int u = -1;
    int mincost = INFTY;
    for (int i = 0; i < N; i++) {
      if (mincost > d[i] && color[i] != BLACK) {
        u = i;
        mincost = d[i];
      }
    }
    if (u == -1) break;
    color[u] = BLACK;
    list[u][par[u]].second = true;
    list[par[u]][u].second = true;
    int next_v = -1;
    for (int v = 0; v < N; v++) {
      if (list[u][v].first != INFTY && color[v] != BLACK) {
        if (d[v] > d[u] + list[u][v].first) {
          d[v] = d[u] + list[u][v].first;
          par[v] = u;
          next_v = v;
          color[v] = GRAY;
        }
      }
    }
  }
}
int main() {
  cin >> N >> M;
  vector<pair<int, int> > edges(M);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) list[i][j] = make_pair(INFTY, false);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    list[a][b] = make_pair(c, false);
    list[b][a] = make_pair(c, false);
    edges[i] = make_pair(a, b);
  }
  for (int i = 0; i < N; i++) {
    dijkstra(i);
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int a = edges[i].first;
    int b = edges[i].second;
    if (!list[a][b].second) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
