#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
long long dist[MAXN][MAXN];
int edg[MAXN][MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) dist[i][j] = 1e13;
  }
  vector<pair<long long, pair<int, int> > > e;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    long long z;
    cin >> z;
    dist[x][y] = z;
    dist[y][x] = z;
    e.push_back({z, {x, y}});
    e.push_back({z, {y, x}});
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k) {
        dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (auto &k : e) {
        if (dist[i][j] ==
            dist[i][k.second.first] + k.first + dist[k.second.second][j])
          edg[k.second.first][k.second.second] = 1,
          edg[k.second.second][k.second.first] = 1;
      }
    }
  }
  int ans = 0;
  for (auto &i : e) {
    if (edg[i.second.first][i.second.second] == 0) ans++;
  }
  ans /= 2;
  return cout << ans << "\n", 0;
}
