#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;
constexpr int mod1 = 998244353;
vector<int> dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
bool inside(int y, int x, int h, int w) {
  if (y < h && y >= 0 && x < w && x >= 0) return true;
  return false;
}
const int inf = 1000000000;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n, inf));
  vector<int> a(m), b(m), c(m);
  for (int i = 0; i < (m); ++i) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
    a.at(i)--;
    b.at(i)--;
    g[a.at(i)][b.at(i)] = c.at(i);
    g[b.at(i)][a.at(i)] = c.at(i);
  }
  vector<vector<int>> dist = g;
  for (int k = 0; k < (n); ++k) {
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (n); ++j) {
        dist[i][j] = min(dist[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (m); ++i) {
    if (g[a.at(i)][b.at(i)] != dist[a.at(i)][b.at(i)]) ans++;
  }
  cout << ans << endl;
}
