#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n, vector<int>(n));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = g[b][a] = c;
  }
  vector<vector<int>> d(g);
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  vector<vector<bool>> used(n, vector<bool>(n, false));
  for (int s = 0; s < n; s++) {
    for (int t = 0; t < n; t++) {
      if (s == t) continue;
      int now = s;
      while (now != t) {
        for (int i = 0; i < n; i++) {
          if (i == now) continue;
          if (g[now][i] + d[i][t] == d[now][t]) {
            used[now][i] = true;
            now = i;
            break;
          }
        }
      }
    }
  }
  int use = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (used[i][j]) use++;
    }
  }
  use >>= 1;
  int ans = m - use;
  cout << ans << endl;
  return 0;
}
