#include <bits/stdc++.h>
using namespace std;
struct data {
  long long a, b, c;
};
long long n, m, p;
long long dist[2600];
vector<data> edge;
vector<vector<bool>> used;
void bell() {
  for (int i = 0; i < m; ++i) {
    data now = edge[i];
    if (dist[now.a] != (long long)1e18 && dist[now.b] > dist[now.a] + now.c) {
      dist[now.b] = dist[now.a] + now.c;
      used[now.a][now.b] = false;
      used[now.b][now.a] = false;
    }
  }
  return;
}
void solve() {
  for (int i = 0; i < n; ++i) dist[i] = (long long)1e18;
  dist[0] = 0;
  for (int i = 0; i < n - 1; ++i) bell();
}
int main() {
  cin >> n >> m;
  used.resize(n, vector<bool>(n, false));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    edge.push_back({--a, --b, c});
    used[a][b] = true;
    used[b][a] = true;
  }
  solve();
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (used[i][j]) cnt++;
  }
  cout << cnt / 2 << endl;
  return 0;
}
