#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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>> gg = g;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (gg[i][k] + gg[k][j] < gg[i][j]) {
          gg[i][j] = gg[i][k] + gg[k][j];
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] != gg[i][j]) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}
