#include <bits/stdc++.h>
using namespace std;
static const int INF = 1 << 22;
long long N;
pair<long long, long long> G[100][100];
long long d[100];
bool used[100];
void dijkstra(int s) {
  vector<long long> pre;
  for (int i = 0; i < 100; i++) {
    d[i] = INF;
    used[i] = false;
  }
  d[s] = 0;
  pre.push_back(s);
  while (true) {
    int v = -1;
    for (int i = 0; i < N; i++) {
      if (!used[i] && (v == -1 || d[i] < d[v])) v = i;
    }
    if (v == -1) break;
    used[v] = true;
    pre.push_back(v);
    for (int i = 0; i < N; i++) {
      if (d[i] > d[v] + G[v][i].first) {
        d[i] = d[v] + G[v][i].first;
      }
    }
  }
  for (int i = 0; i < pre.size() - 1; i++) {
    G[pre[i]][pre[i + 1]].second = 1;
    G[pre[i + 1]][pre[i]].second = 1;
  }
}
int main(void) {
  cin >> N;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      G[i][j].first = INF;
      G[i][j].second = 0;
    }
  }
  long long M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    long long a;
    cin >> a;
    long long b;
    cin >> b;
    long long c;
    cin >> c;
    a--;
    b--;
    G[a][b].first = c;
    G[b][a].first = c;
  }
  for (int i = 0; i < N; i++) {
    dijkstra(i);
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (G[i][j].second == 1) count++;
    }
  }
  cout << M - count << endl;
  return 0;
}
