#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool> > used(n, vector<bool>(n, false));
  vector<vector<int> > graph(n, vector<int>(n, INF));
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    graph[a][b] = c;
    graph[b][a] = c;
    used[a][b] = true;
    used[b][a] = true;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (graph[i][j] > graph[i][k] + graph[k][j]) {
          graph[i][j] = graph[i][k] + graph[k][j];
          graph[j][i] = graph[i][k] + graph[k][j];
          if (used[i][j]) {
            used[i][j] = false;
            used[j][i] = false;
            ans++;
          }
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
